emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/handler-bind 7da237eb092 03/12: edebug.el: Use `handler-bind` in


From: Stefan Monnier
Subject: scratch/handler-bind 7da237eb092 03/12: edebug.el: Use `handler-bind` instead of `signal-hook-function`
Date: Mon, 25 Dec 2023 23:56:51 -0500 (EST)

branch: scratch/handler-bind
commit 7da237eb09284771dca953b81d7b0f6ad7617e75
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    edebug.el: Use `handler-bind` instead of `signal-hook-function`
    
    * lisp/emacs-lisp/edebug.el (edebug-signal): Adjust to new
    calling convention.
    (edebug-default-enter): Use `handler-bind` instead of
    `signal-hook-function`.
    (edebug--recursive-edit): Simplify accordingly.
---
 lisp/emacs-lisp/edebug.el | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index aa68978f6d6..2a1851dee58 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -2261,8 +2261,8 @@ are too difficult to instrument")
 
 ;;; Handling signals
 
-(defun edebug-signal (signal-name signal-data)
-  "Signal an error.  Args are SIGNAL-NAME, and associated DATA.
+(defun edebug-signal (err)
+  "Signal an error.  ERR is the list made of the signal name and its data.
 A signal name is a symbol with an `error-conditions' property
 that is a list of condition names.
 A handler for any of those names will get to handle this signal.
@@ -2272,17 +2272,12 @@ DATA should be a list.  Its elements are printed as 
part of the error message.
 If the signal is handled, DATA is made available to the handler.
 See `condition-case'.
 
-This is the Edebug replacement for the standard `signal'.  It should
-only be active while Edebug is.  It checks `debug-on-error' to see
+This is the error handler installed during Edebug.
+It should only be active while Edebug is.  It checks `debug-on-error' to see
 whether it should call the debugger.  When execution is resumed, the
-error is signaled again."
-  (if (and (listp debug-on-error) (memq signal-name debug-on-error))
-      (edebug 'error (cons signal-name signal-data)))
-  ;; If we reach here without another non-local exit, then send signal again.
-  ;; i.e. the signal is not continuable, yet.
-  ;; Avoid infinite recursion.
-  (let ((signal-hook-function nil))
-    (signal signal-name signal-data)))
+error is propagated further."
+  (if (and (listp debug-on-error) (memq (car err) debug-on-error))
+      (edebug 'error err)))
 
 ;;; Entering Edebug
 
@@ -2326,7 +2321,7 @@ and run its entry function, and set up `edebug-before' and
               (debug-on-error (or debug-on-error edebug-on-error))
               (debug-on-quit edebug-on-quit))
           (unwind-protect
-              (let ((signal-hook-function #'edebug-signal))
+              (handler-bind ((error #'edebug-signal))
                 (setq edebug-execution-mode (or edebug-next-execution-mode
                                                 edebug-initial-mode
                                                 edebug-execution-mode)
@@ -2937,14 +2932,11 @@ when edebug becomes active."
               (not (memq arg-mode '(after error))))
          (message "Break"))
 
-      (setq signal-hook-function nil)
-
       (edebug-mode 1)
       (unwind-protect
          (recursive-edit)              ;  <<<<<<<<<< Recursive edit
 
        ;; Do the following, even if quit occurs.
-       (setq signal-hook-function #'edebug-signal)
        (if edebug-backtrace-buffer
            (kill-buffer edebug-backtrace-buffer))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]