Split doom-reload-hook into before/after hooks

This commit is contained in:
Henrik Lissner 2020-10-16 22:28:08 -04:00
parent a835be1c40
commit 35185b2175
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 11 additions and 8 deletions

View file

@ -3,10 +3,6 @@
(defvar doom-bin-dir (concat doom-emacs-dir "bin/"))
(defvar doom-bin (concat doom-bin-dir "doom"))
;;;###autoload
(defvar doom-reload-hook nil
"A list of hooks to run when `doom/reload' is called.")
;;;###autoload
(defvar doom-reloading-p nil
"TODO")
@ -76,7 +72,7 @@ This is experimental! It will try to do as `bin/doom sync' does, but from within
this Emacs session. i.e. it reload autoloads files (if necessary), reloads your
package list, and lastly, reloads your private config.el.
Runs `doom-reload-hook' afterwards."
Runs `doom-after-reload-hook' afterwards."
(interactive)
(require 'core-cli)
(when (and IS-WINDOWS (file-exists-p doom-env-file))
@ -86,13 +82,14 @@ Runs `doom-reload-hook' afterwards."
(mapc #'require (cdr doom-incremental-packages))
(doom--if-compile (format "%s sync -e" doom-bin)
(let ((doom-reloading-p t))
(run-hook-wrapped 'doom-before-reload-hook #'doom-try-run-hook)
(doom-initialize 'force)
(with-demoted-errors "PRIVATE CONFIG ERROR: %s"
(general-auto-unbind-keys)
(unwind-protect
(doom-initialize-modules 'force)
(general-auto-unbind-keys t)))
(run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook)
(run-hook-wrapped 'doom-after-reload-hook #'doom-try-run-hook)
(message "Config successfully reloaded!"))
(user-error "Failed to reload your config")))

View file

@ -473,6 +473,12 @@ If this is a daemon session, load them all immediately instead."
(defvar doom-first-buffer-hook nil
"Transient hooks run before the first interactively opened buffer.")
(defvar doom-after-reload-hook nil
"A list of hooks to run before `doom/reload' has reloaded Doom.")
(defvar doom-before-reload-hook nil
"A list of hooks to run after `doom/reload' has reloaded Doom.")
;;
;;; Bootstrap helpers

View file

@ -360,7 +360,7 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(setf (alist-get fn ivy-posframe-display-functions-alist)
#'ivy-display-function-fallback))
(add-hook 'doom-reload-hook #'posframe-delete-all))
(add-hook 'doom-after-reload-hook #'posframe-delete-all))
(use-package! flx

View file

@ -62,7 +62,7 @@
;; HACK The fringe cannot have a buffer-local remapping on Emacs <= 26, so
;; we jump through hoops to reset it (globally) whenever it is likely
;; that the fringe will have lost its background color.
(add-hook! '(doom-load-theme-hook doom-reload-hook) :append
(add-hook! '(doom-load-theme-hook doom-after-reload-hook) :append
#'solaire-mode-reset)
;; fringe can become unstyled when deleting or focusing frames