tweak(lib): log calling hook from doom-run-hook

Makes it easier to trace hooks through logs.
This commit is contained in:
Henrik Lissner 2022-09-24 21:17:40 +02:00
parent 4efaf6837b
commit 1c32e317cc
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -204,9 +204,11 @@ unreadable. Returns the names of envvars that were changed."
(set-time-zone-rule newtz))))
env))))
(defvar doom--hook nil)
(defun doom-run-hook (hook)
"Run HOOK (a hook function) with better error handling.
Meant to be used with `run-hook-wrapped'."
(doom-log "hook:%s: run %s" (or doom--hook '*) hook)
(condition-case-unless-debug e
(funcall hook)
(error
@ -219,7 +221,8 @@ Meant to be used with `run-hook-wrapped'."
Is used as advice to replace `run-hooks'."
(dolist (hook hooks)
(condition-case-unless-debug e
(run-hook-wrapped hook #'doom-run-hook)
(let ((doom--hook hook))
(run-hook-wrapped hook #'doom-run-hook))
(doom-hook-error
(unless debug-on-error
(lwarn hook :error "Error running hook %S because: %s"