Add doom-run-hooks

Produces more helpful (and harder-to-miss) error messages when a hook
emits an error. Also advises run-hook when doom-debug-mode is active, so
errors in hooks (generally, major mode hooks) don't quietly go
unnoticed.
This commit is contained in:
Henrik Lissner 2021-05-05 16:12:35 -04:00
parent df10383a26
commit ff64a9d106
6 changed files with 35 additions and 20 deletions

View file

@ -675,7 +675,11 @@ This offers a moderate boost in startup (or theme switch) time, so long as
(defun doom-init-ui-h ()
"Initialize Doom's user interface by applying all its advice and hooks."
(run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook)
;; Produce more helpful (and visible) error messages from errors emitted from
;; hooks (particularly mode hooks, that usually go unnoticed otherwise.
(advice-add #'run-hooks :override #'doom-run-hooks)
(doom-run-hooks 'doom-init-ui-hook)
(add-hook 'kill-buffer-query-functions #'doom-protect-fallback-buffer-h)
(add-hook 'after-change-major-mode-hook #'doom-highlight-non-default-indentation-h 'append)