summaryrefslogtreecommitdiff
path: root/corfu.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2025-05-16 18:04:01 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2025-05-16 18:04:01 +0200
commit52b6c0ec4903a87f905ec8ee547a77f28196502d (patch)
tree379847de81f1a4ba058aec39a854a6323aa44257 /corfu.el
parent6b1a223ddbfabdfda048ea4c2c13182453e1cb68 (diff)
corfu--protect: Use handler-bind on Emacs 30
Diffstat (limited to 'corfu.el')
-rw-r--r--corfu.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/corfu.el b/corfu.el
index 02fada9..7d95650 100644
--- a/corfu.el
+++ b/corfu.el
@@ -868,14 +868,18 @@ the last command must be listed in `corfu-continue-commands'."
"Protect FUN such that errors are caught.
If an error occurs, the FUN is retried with `debug-on-error' enabled and
the stack trace is shown in the *Messages* buffer."
- (when (or debug-on-error (condition-case nil
- (progn (funcall fun) nil)
- (error t)))
- (let ((debug-on-error t)
- (debugger #'corfu--debug))
- (condition-case nil
- (funcall fun)
- ((debug error) nil)))))
+ (static-if (>= emacs-major-version 30)
+ (ignore-errors
+ (handler-bind ((error #'corfu--debug))
+ (funcall fun)))
+ (when (or debug-on-error (condition-case nil
+ (progn (funcall fun) nil)
+ (error t)))
+ (let ((debug-on-error t)
+ (debugger #'corfu--debug))
+ (condition-case nil
+ (funcall fun)
+ ((debug error) nil))))))
(defun corfu--post-command ()
"Refresh Corfu after last command."