From 31f0f0a9c7b8e1b7edf0309fc523d67ec90874f2 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 8 Sep 2021 09:58:15 -0700 Subject: Catch and report all errors raised when invoking command hooks * exwm-input.el (exwm-input--fake-last-command): Catch and report all errors raised when invoking `pre-command-hook' and `post-command-hook'. Copyright-paperwork-exempt: yes --- exwm-input.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index be3e8f465f..05b021093c 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -668,8 +668,26 @@ Current buffer must be an `exwm-mode' buffer." (defun exwm-input--fake-last-command () "Fool some packages into thinking there is a change in the buffer." (setq last-command #'exwm-input--noop) - (run-hooks 'pre-command-hook) - (run-hooks 'post-command-hook)) + ;; The Emacs manual says: + ;; > Quitting is suppressed while running pre-command-hook and + ;; > post-command-hook. If an error happens while executing one of these + ;; > hooks, it does not terminate execution of the hook; instead the error is + ;; > silenced and the function in which the error occurred is removed from the + ;; > hook. + ;; We supress errors but neither continue execution nor we remove from the + ;; hook. + (condition-case err + (run-hooks 'pre-command-hook) + ((error) + (exwm--log "Error occurred while running pre-command-hook: %s" + (error-message-string err)) + (xcb-debug:backtrace))) + (condition-case err + (run-hooks 'post-command-hook) + ((error) + (exwm--log "Error occurred while running post-command-hook: %s" + (error-message-string err)) + (xcb-debug:backtrace)))) (defun exwm-input--on-KeyPress-line-mode (key-press raw-data) "Parse X KeyPress event to Emacs key event and then feed the command loop." -- cgit 1.4.1