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

View File

@ -52,33 +52,25 @@
(use-package diminish) (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" ;; emacs --batch -l "~/.emacs.d/init.el" -f "my/upgrade-packages"
(defun my/upgrade-packages () (defun my/upgrade-packages ()
"Upgrade all packages installed with straight." "Upgrade all packages installed with straight."
(interactive) (interactive)
(straight-pull-recipe-repositories) ;; TODO is this needed? (setq-local force-reload t)
(straight-pull-recipe-repositories)
(straight-x-fetch-all) (straight-x-fetch-all)
(while straight-x-running
(sleep-for 1))
(straight-merge-all) (straight-merge-all)
(reload-init)
(straight-check-all) (straight-check-all)
;; Do this automatically, as we can always revert and thaw (straight-freeze-versions))
(run-straight-lock-file-function 'straight-freeze-versions))
;; emacs --batch -l "~/.emacs.d/init.el" -f "my/thaw-packages" ;; emacs --batch -l "~/.emacs.d/init.el" -f "my/thaw-packages"
(defun my/thaw-packages () (defun my/thaw-packages ()
"Restore all packages to the versions in the straight lockfile." "Restore all packages to the versions in the straight lockfile."
(interactive) (interactive)
(run-straight-lock-file-function 'straight-thaw-versions)) (setq-local force-reload t)
(straight-thaw-versions))
(provide 'init-packages) (provide 'init-packages)
;;; init-packages.el ends here ;;; init-packages.el ends here