Try a difference approach to upgraded packages

This commit is contained in:
David Morgan 2022-10-18 16:27:27 +01:00
parent e1f7d9ddcd
commit 0b7b8e2e79
Signed by: djm
GPG Key ID: C171251002C200F2
2 changed files with 44 additions and 44 deletions

View File

@ -28,34 +28,42 @@
(setq gc-cons-threshold (* 100 1024 1024)
gc-cons-percentage 0.1)))
(require 'init-packages)
(require 'init-ui)
(require 'init-compile)
(require 'init-editor)
(require 'init-search)
(require 'init-windows)
(require 'init-project)
(require 'init-modeline)
(require 'init-completion)
(require 'init-minibuffer)
(require 'init-navigation)
(require 'init-kill)
(require 'init-dired)
(require 'init-smartparens)
(require 'init-emacs-lisp)
(require 'init-clojure)
(require 'init-paredit)
(require 'init-crux)
(require 'init-lsp)
(require 'init-git)
(require 'init-shell)
(require 'init-org)
;;(require 'init-latex)
(require 'init-xml)
(require 'init-web)
(require 'init-misc)
(require 'init-tramp)
(require 'init-sql)
(require 'init-local nil t)
;; Some straight functions need to be able to reload everything, so require won't do
(defun require! (feature &optional filename noerror)
"Like `require', but if `force-reload' is non-nil, `load' instead.
`FEATURE', `FILENAME' and `NOERROR' have the same meaning as with require"
(if (and (boundp 'force-reload) force-reload)
(load (prin1-to-string feature) noerror nil nil t)
(require feature filename noerror)))
(require! 'init-packages)
(require! 'init-ui)
(require! 'init-compile)
(require! 'init-editor)
(require! 'init-search)
(require! 'init-windows)
(require! 'init-project)
(require! 'init-modeline)
(require! 'init-completion)
(require! 'init-minibuffer)
(require! 'init-navigation)
(require! 'init-kill)
(require! 'init-dired)
(require! 'init-smartparens)
(require! 'init-emacs-lisp)
(require! 'init-clojure)
(require! 'init-paredit)
(require! 'init-crux)
(require! 'init-lsp)
(require! 'init-git)
(require! 'init-shell)
(require! 'init-org)
;;(require! 'init-latex)
(require! 'init-xml)
(require! 'init-web)
(require! 'init-misc)
(require! 'init-tramp)
(require! 'init-sql)
(require! 'init-local nil t)
;;; init.el ends here

View File

@ -52,33 +52,25 @@
(use-package diminish)
(defun run-straight-lock-file-function (func)
"Safely run straight lockfile-related function `FUNC'.
This will remove all init-* files from `features', so that they are reloaded."
(setq features (seq-filter '(lambda (elt) (not (string-prefix-p "init-" (prin1-to-string elt)))) features))
(funcall func))
(defun reload-init ()
"Reload `user-init-file', ensuring that requires are reloaded."
(run-straight-lock-file-function #'(lambda () (load (or user-init-file "~/.emacs.d/init.el") nil 'nomessage))))
;; emacs --batch -l "~/.emacs.d/init.el" -f "my/upgrade-packages"
(defun my/upgrade-packages ()
"Upgrade all packages installed with straight."
(interactive)
(straight-pull-recipe-repositories) ;; TODO is this needed?
(setq-local force-reload t)
(straight-pull-recipe-repositories)
(straight-x-fetch-all)
(while straight-x-running
(sleep-for 1))
(straight-merge-all)
(reload-init)
(straight-check-all)
;; Do this automatically, as we can always revert and thaw
(run-straight-lock-file-function 'straight-freeze-versions))
(straight-freeze-versions))
;; emacs --batch -l "~/.emacs.d/init.el" -f "my/thaw-packages"
(defun my/thaw-packages ()
"Restore all packages to the versions in the straight lockfile."
(interactive)
(run-straight-lock-file-function 'straight-thaw-versions))
(setq-local force-reload t)
(straight-thaw-versions))
(provide 'init-packages)
;;; init-packages.el ends here