Refactor doom-load-packages-incrementally

This commit is contained in:
Henrik Lissner 2019-10-18 22:08:58 -04:00
parent 43e8ddbc6d
commit 7b45b39860
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -349,29 +349,30 @@ If NOW is non-nil, load PACKAGES incrementally, in `doom-incremental-idle-timer'
intervals." intervals."
(if (not now) (if (not now)
(nconc doom-incremental-packages packages) (nconc doom-incremental-packages packages)
(when packages (while packages
(let ((gc-cons-threshold most-positive-fixnum) (let ((req (pop packages)))
(file-name-handler-alist nil) (unless (featurep req)
(reqs (cl-delete-if #'featurep packages)))
(when-let (req (if reqs (pop reqs)))
(doom-log "Incrementally loading %s" req) (doom-log "Incrementally loading %s" req)
(condition-case e (condition-case e
(or (while-no-input (or (while-no-input
;; If `default-directory' is a directory that doesn't exist ;; If `default-directory' is a directory that doesn't exist
;; or is unreadable, Emacs throws up file-missing errors, so ;; or is unreadable, Emacs throws up file-missing errors, so
;; we set it to a directory we know exists and is readable. ;; we set it to a directory we know exists and is readable.
(let ((default-directory doom-emacs-dir)) (let ((default-directory doom-emacs-dir)
(gc-cons-threshold most-positive-fixnum)
file-name-handler-alist)
(require req nil t)) (require req nil t))
t) t)
(push req reqs)) (push req packages))
((error debug) ((error debug)
(message "Failed to load '%s' package incrementally, because: %s" (message "Failed to load '%s' package incrementally, because: %s"
req e))) req e)))
(if reqs (if (not packages)
(doom-log "Finished incremental loading")
(run-with-idle-timer doom-incremental-idle-timer (run-with-idle-timer doom-incremental-idle-timer
nil #'doom-load-packages-incrementally nil #'doom-load-packages-incrementally
reqs t) packages t)
(doom-log "Finished incremental loading"))))))) (setq packages nil)))))))
(defun doom-load-packages-incrementally-h () (defun doom-load-packages-incrementally-h ()
"Begin incrementally loading packages in `doom-incremental-packages'. "Begin incrementally loading packages in `doom-incremental-packages'.