Improve error handling in doom-first-*-hook

This should at least report what function invoked the error.
doom-first-input-hook was especially problematic because it runs on
pre-command-hook, which Emacs is very protective of. It will smother
errors that arise from it and auto-remove the offending hook. This
self-correction is nice for avoiding a broken Emacs, but it makes it
tough to debug those issues.
This commit is contained in:
Henrik Lissner 2020-08-02 18:40:57 -04:00
parent c3be74139a
commit a9bd4965bf
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -490,7 +490,10 @@ advised)."
(defmacro add-hook-trigger! (hook-var &rest targets)
"TODO"
`(let ((fn (intern (format "%s-h" ,hook-var))))
(fset fn (lambda (&rest _) (run-hooks ,hook-var) (set ,hook-var nil)))
(fset
fn (lambda (&rest _)
(run-hook-wrapped ,hook-var #'doom-try-run-hook)
(set ,hook-var nil)))
(put ,hook-var 'permanent-local t)
(dolist (on (list ,@targets))
(if (functionp on)