From ea4d0a50cb05545dfc839dc55957c0a3fef1f4cb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 12 Jul 2017 23:58:36 +0200 Subject: [PATCH] Refactor doom-initialize-packages It reloaded Doom too aggressively. No more. --- core/core-packages.el | 51 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index 2226ac291..70efd0cfe 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -178,7 +178,7 @@ to speed up startup." (unless (file-exists-p doom-autoload-file) (quiet! (doom/reload-autoloads)))) -(defun doom-initialize-packages (&optional force-p load-p) +(defun doom-initialize-packages (&optional force-p) "Crawls across your emacs.d to fill `doom-modules' (from init.el) and `doom-packages' (from packages.el files), if they aren't set already. @@ -186,33 +186,26 @@ If FORCE-P is non-nil, do it even if they are. This aggressively reloads core autoload files." (doom-initialize force-p) - (let ((noninteractive t) - (load-fn - (lambda (file &optional noerror) - (condition-case-unless-debug ex - (load file noerror :nomessage :nosuffix) - ('error - (error (format "(doom-initialize-packages) %s in %s: %s" - (car ex) - (file-relative-name file doom-emacs-dir) - (error-message-string ex)) - :error)))))) - (when (or force-p (not doom-modules)) - (setq doom-modules nil) - (funcall load-fn (expand-file-name "init.el" doom-emacs-dir)) - (funcall load-fn (doom-module-path :private user-login-name "init.el") t) - (when load-p - (cl-loop for file - in (append (nreverse (file-expand-wildcards (expand-file-name "core*.el" doom-core-dir))) - (file-expand-wildcards (expand-file-name "autoload/*.el" doom-core-dir)) - (doom--module-paths "config.el")) - do (funcall load-fn file t))) - (doom|finalize)) - (when (or force-p (not doom-packages)) - (setq doom-packages nil) - (funcall load-fn (expand-file-name "packages.el" doom-core-dir)) - (dolist (file (doom--module-paths "packages.el")) - (funcall load-fn file t))))) + (unwind-protect + (let ((noninteractive t) + (load-fn + (lambda (file &optional noerror) + (condition-case-unless-debug ex + (load file noerror :nomessage :nosuffix) + ('error + (error (format "(doom-initialize-packages) %s in %s: %s" + (car ex) + (file-relative-name file doom-emacs-dir) + (error-message-string ex)))))))) + (when (or force-p (not doom-modules)) + (setq doom-modules nil) + (funcall load-fn (expand-file-name "init.el" doom-emacs-dir))) + (when (or force-p (not doom-packages)) + (setq doom-packages nil) + (funcall load-fn (expand-file-name "packages.el" doom-core-dir)) + (dolist (file (doom--module-paths "packages.el")) + (funcall load-fn file t)))) + (doom|finalize))) (defun doom-initialize-modules (modules) "Adds MODULES to `doom-modules'. MODULES must be in mplist format. @@ -569,7 +562,7 @@ If ONLY-RECOMPILE-P is non-nil, only recompile out-of-date files." (interactive "P") ;; Ensure all relevant config files are loaded and up-to-date. This way we ;; don't need eval-when-compile and require blocks scattered all over. - (doom-initialize-packages t noninteractive) + (doom-initialize-packages t) (let ((targets (cond ((equal (car command-line-args-left) "--") (cl-loop for file in (cdr command-line-args-left)