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."
(if (not now)
(nconc doom-incremental-packages packages)
(when packages
(let ((gc-cons-threshold most-positive-fixnum)
(file-name-handler-alist nil)
(reqs (cl-delete-if #'featurep packages)))
(when-let (req (if reqs (pop reqs)))
(while packages
(let ((req (pop packages)))
(unless (featurep req)
(doom-log "Incrementally loading %s" req)
(condition-case e
(or (while-no-input
;; If `default-directory' is a directory that doesn't exist
;; or is unreadable, Emacs throws up file-missing errors, so
;; 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))
t)
(push req reqs))
(push req packages))
((error debug)
(message "Failed to load '%s' package incrementally, because: %s"
req e)))
(if reqs
(if (not packages)
(doom-log "Finished incremental loading")
(run-with-idle-timer doom-incremental-idle-timer
nil #'doom-load-packages-incrementally
reqs t)
(doom-log "Finished incremental loading")))))))
packages t)
(setq packages nil)))))))
(defun doom-load-packages-incrementally-h ()
"Begin incrementally loading packages in `doom-incremental-packages'.