diff options
author | David Wilson <david@daviwil.com> | 2021-09-08T16·58-0700 |
---|---|---|
committer | Adrián Medraño Calvo <adrian@medranocalvo.com> | 2023-09-11T00·00+0000 |
commit | 31f0f0a9c7b8e1b7edf0309fc523d67ec90874f2 (patch) | |
tree | bcffc3eec6479fa49e0f286b1585bcdd55c77334 /exwm-input.el | |
parent | 381637aa1c7b82671fab4cfdadebee590f7c1c45 (diff) |
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
Diffstat (limited to 'exwm-input.el')
-rw-r--r-- | exwm-input.el | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el index be3e8f465f71..05b021093c20 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." |