fix(profiles): not loading $EMACSDIR/init.el

`startup--load-user-init-file` persists its original
user-emacs-directory in a lexical binding that we cannot affect from
early-init.el, and uses it to find init.el. This prevents non-Doom
profiles' init.el files from being loaded.

A way around this is to have our own $EMACSDIR/init.el that loads
{user-emacs-directory}/init.el, but that's unnecessary work and ruins
our users' ability to use their $EMACSDIR as their $DOOMDIR, so I opted
for advice instead, to force it to recognize the changed
user-emacs-directory.

Fix: https://discourse.doomemacs.org/t/3251
This commit is contained in:
Henrik Lissner 2022-10-02 18:06:58 +02:00
parent d8d06390d2
commit 7aa87eb019
No known key found for this signature in database
GPG Key ID: B60957CA074D39A3

View File

@ -111,6 +111,13 @@
nil (not init-file-debug) nil 'must-suffix)
;; Failing that, assume that we're loading a non-Doom config.
(file-missing
;; HACK: `startup--load-user-init-file' resolves $EMACSDIR from a
;; lexically bound `startup-init-directory', which means changes
;; to `user-emacs-directory' won't be respected when loading
;; $EMACSDIR/init.el, so I force it to:
(define-advice startup--load-user-init-file (:filter-args (args) reroute-to-profile)
(list (lambda () (expand-file-name "init.el" user-emacs-directory))
nil (nth 2 args)))
;; Set `user-init-file' for the `load' call further below, and do so
;; here while our `file-name-handler-alist' optimization is still
;; effective (benefits `expand-file-name'). BTW: Emacs resets