Reset more state on doom/module initialization

Makes `doom/reload` a little more reliable and the side effects of
`doom-initialize`/`doom-initialize-modules` a little more deterministic.
This commit is contained in:
Henrik Lissner 2019-04-09 03:43:13 -04:00
parent defd60b24b
commit 31eb845f6b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 22 additions and 5 deletions

View file

@ -33,11 +33,11 @@ Runs `doom-reload-hook' afterwards."
(when (getenv "DOOMENV") (when (getenv "DOOMENV")
(doom-reload-env-file 'force)) (doom-reload-env-file 'force))
(doom-reload-autoloads force-p) (doom-reload-autoloads force-p)
(setq load-path doom-site-load-path)
(let (doom-init-p) (let (doom-init-p)
(doom-initialize)) (doom-initialize))
(with-demoted-errors "PRIVATE CONFIG ERROR: %s" (with-demoted-errors "PRIVATE CONFIG ERROR: %s"
(doom-initialize-modules 'force)) (let (doom-init-modules-p)
(doom-initialize-modules)))
(when (bound-and-true-p doom-packages) (when (bound-and-true-p doom-packages)
(doom/reload-packages)) (doom/reload-packages))
(run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook)) (run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook))

View file

@ -59,6 +59,7 @@ session of Dooming. Will noop if used more than once, unless FORCE-P is
non-nil." non-nil."
(when (and (or force-p (when (and (or force-p
(not doom-init-modules-p)) (not doom-init-modules-p))
(not (setq doom-modules nil))
(load! "init" doom-private-dir t)) (load! "init" doom-private-dir t))
(setq doom-init-modules-p t) (setq doom-init-modules-p t)
(maphash (lambda (key plist) (maphash (lambda (key plist)

View file

@ -98,11 +98,21 @@ MacOS users).")
"If non-nil, the running version of Emacs is different from the first time "If non-nil, the running version of Emacs is different from the first time
Doom was setup, which can cause problems.") Doom was setup, which can cause problems.")
(defvar doom-site-load-path load-path (defvar doom-site-load-path (cons doom-core-dir load-path)
"The starting `load-path', before it is altered by `doom-initialize'.") "The initial value of `load-path', before it was altered by
`doom-initialize'.")
(defvar doom-site-process-environment process-environment (defvar doom-site-process-environment process-environment
"The starting `process-environment', before it is altered by `doom-initialize'.") "The initial value of `process-environment', before it was altered by
`doom-initialize'.")
(defvar doom-site-exec-path exec-path
"The initial value of `exec-path', before it was altered by
`doom-initialize'.")
(defvar doom-site-shell-file-name shell-file-name
"The initial value of `shell-file-name', before it was altered by
`doom-initialize'.")
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el")) (defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
(defvar doom--last-emacs-version nil) (defvar doom--last-emacs-version nil)
@ -431,6 +441,12 @@ to least)."
(when (or force-p (not doom-init-p)) (when (or force-p (not doom-init-p))
(setq doom-init-p t) ; Prevent infinite recursion (setq doom-init-p t) ; Prevent infinite recursion
;; Reset as much state as possible
(setq exec-path doom-site-exec-path
load-path doom-site-load-path
process-environment doom-site-process-environment
shell-file-name doom-site-shell-file-name)
;; `doom-autoload-file' tells Emacs where to load all its autoloaded ;; `doom-autoload-file' tells Emacs where to load all its autoloaded
;; functions from. This includes everything in core/autoload/*.el and all ;; functions from. This includes everything in core/autoload/*.el and all
;; the autoload files in your enabled modules. ;; the autoload files in your enabled modules.