branch: externals/corfu
commit 52b6c0ec4903a87f905ec8ee547a77f28196502d
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    corfu--protect: Use handler-bind on Emacs 30
---
 corfu.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/corfu.el b/corfu.el
index 02fada9261..7d9565098b 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."

Reply via email to