Revert "Refactor doom-initialize-packages"

This reverts commit ea4d0a50cb.

Fixes #148
This commit is contained in:
Henrik Lissner 2017-07-26 17:07:10 +02:00
parent 1d15a22bc3
commit aa255d9cb6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -185,7 +185,7 @@ to speed up startup."
(unless (file-exists-p doom-autoload-file) (unless (file-exists-p doom-autoload-file)
(quiet! (doom/reload-autoloads)))) (quiet! (doom/reload-autoloads))))
(defun doom-initialize-packages (&optional force-p) (defun doom-initialize-packages (&optional force-p load-p)
"Crawls across your emacs.d to fill `doom-modules' (from init.el) and "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. `doom-packages' (from packages.el files), if they aren't set already.
@ -193,28 +193,33 @@ If FORCE-P is non-nil, do it even if they are.
This aggressively reloads core autoload files." This aggressively reloads core autoload files."
(doom-initialize force-p) (doom-initialize force-p)
(unwind-protect (let ((noninteractive t)
(let ((noninteractive t) (load-fn
(load-fn (lambda (file &optional noerror)
(lambda (file &optional noerror) (condition-case-unless-debug ex
(condition-case-unless-debug ex (load file noerror :nomessage :nosuffix)
(load file noerror :nomessage :nosuffix) ('error
('error (error (format "(doom-initialize-packages) %s in %s: %s"
(error (format "(doom-initialize-packages) %s in %s: %s" (car ex)
(car ex) (file-relative-name file doom-emacs-dir)
(file-relative-name file doom-emacs-dir) (error-message-string ex))
(error-message-string ex)))))))) :error))))))
(when (or force-p (not doom-modules)) (when (or force-p (not doom-modules))
(setq doom-modules nil) (setq doom-modules nil)
(funcall load-fn (expand-file-name "init.el" doom-emacs-dir)) (funcall load-fn (expand-file-name "init.el" doom-emacs-dir))
(dolist (file (directory-files doom-core-dir t "core-[^.]+\\.el$" t)) (funcall load-fn (doom-module-path :private user-login-name "init.el") t)
(funcall load-fn file))) (when load-p
(when (or force-p (not doom-packages)) (cl-loop for file
(setq doom-packages nil) in (append (nreverse (file-expand-wildcards (expand-file-name "core*.el" doom-core-dir)))
(funcall load-fn (expand-file-name "packages.el" doom-core-dir)) (file-expand-wildcards (expand-file-name "autoload/*.el" doom-core-dir))
(dolist (file (doom--module-paths "packages.el")) (doom--module-paths "config.el"))
(funcall load-fn file t)))) do (funcall load-fn file t)))
(doom|finalize))) (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)))))
(defun doom-initialize-modules (modules) (defun doom-initialize-modules (modules)
"Adds MODULES to `doom-modules'. MODULES must be in mplist format. "Adds MODULES to `doom-modules'. MODULES must be in mplist format.
@ -571,7 +576,7 @@ If ONLY-RECOMPILE-P is non-nil, only recompile out-of-date files."
(interactive "P") (interactive "P")
;; Ensure all relevant config files are loaded and up-to-date. This way we ;; 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. ;; don't need eval-when-compile and require blocks scattered all over.
(doom-initialize-packages t) (doom-initialize-packages t noninteractive)
(let ((targets (let ((targets
(cond ((equal (car command-line-args-left) "--") (cond ((equal (car command-line-args-left) "--")
(cl-loop for file in (cdr command-line-args-left) (cl-loop for file in (cdr command-line-args-left)