Reduce doom-module-table calls significantly

This commit is contained in:
Henrik Lissner 2018-05-25 01:17:01 +02:00
parent 11705d0920
commit a390ef8deb
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -309,8 +309,7 @@ Use this before any of package.el, quelpa or Doom's package management's API to
ensure all the necessary package metadata is initialized and available for ensure all the necessary package metadata is initialized and available for
them." them."
(with-temp-buffer ; prevent buffer-local settings from propagating (with-temp-buffer ; prevent buffer-local settings from propagating
(let ((load-prefer-newer t) ; reduce stale code issues (let ((load-prefer-newer t)) ; reduce stale code issues
(doom-modules (doom-module-table)))
;; package.el and quelpa handle themselves if their state changes during ;; package.el and quelpa handle themselves if their state changes during
;; the current session, but if you change an packages.el file in a module, ;; the current session, but if you change an packages.el file in a module,
;; there's no non-trivial way to detect that, so we give you a way to ;; there's no non-trivial way to detect that, so we give you a way to
@ -338,26 +337,27 @@ them."
(error "Could not initialize quelpa")))) (error "Could not initialize quelpa"))))
(when (or force-p (not doom-packages)) (when (or force-p (not doom-packages))
(setq doom-packages nil) (let ((doom-modules (doom-module-table)))
(cl-flet (setq doom-packages nil)
((_load (cl-flet
(file &optional noerror interactive) ((_load
(condition-case-unless-debug ex (file &optional noerror interactive)
(let ((noninteractive (not interactive))) (condition-case-unless-debug ex
(load file noerror 'nomessage 'nosuffix)) (let ((noninteractive (not interactive)))
('error (load file noerror 'nomessage 'nosuffix))
(lwarn 'doom-initialize-packages :warning ('error
"%s in %s: %s" (lwarn 'doom-initialize-packages :warning
(car ex) "%s in %s: %s"
(file-relative-name file doom-emacs-dir) (car ex)
(error-message-string ex)))))) (file-relative-name file doom-emacs-dir)
(let ((doom--stage 'packages)) (error-message-string ex))))))
(_load (expand-file-name "packages.el" doom-core-dir)) (let ((doom--stage 'packages))
(cl-loop for key being the hash-keys of doom-modules (_load (expand-file-name "packages.el" doom-core-dir))
for path = (doom-module-path (car key) (cdr key) "packages.el") (cl-loop for key being the hash-keys of doom-modules
do (let ((doom--current-module key)) (_load path t))) for path = (doom-module-path (car key) (cdr key) "packages.el")
(cl-loop for dir in doom-psuedo-module-dirs do (let ((doom--current-module key)) (_load path t)))
do (_load (expand-file-name "packages.el" dir) t)))))))) (cl-loop for dir in doom-psuedo-module-dirs
do (_load (expand-file-name "packages.el" dir) t)))))))))
;; ;;