From a9bd4965bf41f103e6c6f1167fcdba417839ea0e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 2 Aug 2020 18:40:57 -0400 Subject: [PATCH] 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. --- core/core-lib.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/core-lib.el b/core/core-lib.el index 6d6cf6923..8ee68e8e4 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -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)