feat(lib): profiles: more portable load-path/Info-directory-list

The Emacs appimage generates a new mountpoint on each invokation, but
Doom's profiles assume that the Emacs directories don't move. To make
Doom's profiles a little more profile, it will no longer set `load-path`
and simply add the new paths to the existing one. Same for
Info-directory-list.

Consequently, this also seems to speed up startup times for ~8% in my
tests. Neat.
This commit is contained in:
Henrik Lissner
2025-09-15 15:12:22 -04:00
parent 4e22e681cd
commit b72fe2bd37

View File

@@ -317,9 +317,22 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
(defun doom-profile--generate-vars ()
`((defun doom--startup-vars ()
,@(cl-loop for var in doom-autoloads-cached-vars
if (boundp var)
collect `(set-default ',var ',(symbol-value var)))
(when (doom-context-p 'reload)
(set-default-toplevel-value 'load-path (get 'load-path 'initial-value)))
,@(cl-loop for var in '(auto-mode-alist
interpreter-mode-alist
magic-mode-alist
magic-fallback-mode-alist)
collect `(set-default-toplevel-value ',var ',(symbol-value var)))
,@(cl-loop with site-run-dir =
(ignore-errors
(directory-file-name (file-name-directory
(locate-library site-run-file))))
for path in load-path
unless (and site-run-dir (file-in-directory-p path site-run-dir))
unless (file-in-directory-p path data-directory)
unless (file-equal-p path doom-core-dir)
collect `(add-to-list 'load-path ,path))
,@(cl-loop with v = (version-to-list doom-version)
with ref = (doom-call-process "git" "-C" (doom-path doom-emacs-dir) "rev-parse" "HEAD")
with branch = (doom-call-process "git" "-C" (doom-path doom-emacs-dir) "branch" "--show-current")
@@ -431,15 +444,13 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
doom-autoloads-excluded-files
'literal))
,@(when-let* ((info-dirs
(cl-loop for key in (hash-table-keys straight--build-cache)
for dir = (straight--build-dir key)
for file = (straight--build-file dir "dir")
if (file-exists-p file)
(cl-loop for dir in load-path
if (file-exists-p (doom-path dir "dir"))
collect dir)))
`((require 'info)
`((with-eval-after-load 'info
(info-initialize)
(setq Info-directory-list
(append ',info-dirs Info-directory-list)))))))
(dolist (path ',(delete-dups info-dirs))
(add-to-list 'Info-directory-list path))))))))
(provide 'doom-lib '(profiles))
;;; profiles.el ends here