emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/transient fd2695d12c 217/366: transient--with-emergency


From: Jonas Bernoulli
Subject: [elpa] externals/transient fd2695d12c 217/366: transient--with-emergency-exit: Wrap default debug function
Date: Tue, 25 Jan 2022 18:54:42 -0500 (EST)

branch: externals/transient
commit fd2695d12c76d504cb9d7e705b22e9cb547639d5
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient--with-emergency-exit: Wrap default debug function
    
    Previously we tried to use the `debug-mode-hook' (which is called
    by `debug') to take the emergency exit, but that was not reliable
    because, that hook is only called if the *Backtrace* buffer does
    not happen to already exit.
---
 lisp/transient.el | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index 0ede50b365..8cc93a5bc9 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -92,11 +92,16 @@
 (defmacro transient--with-emergency-exit (&rest body)
   (declare (indent defun))
   `(condition-case err
-       ,(macroexp-progn body)
+       (let ((debugger #'transient--exit-and-debug))
+         ,(macroexp-progn body))
      ((debug error)
       (transient--emergency-exit)
       (signal (car err) (cdr err)))))
 
+(defun transient--exit-and-debug (&rest args)
+  (transient--emergency-exit)
+  (apply #'debug args))
+
 ;;; Options
 
 (defgroup transient nil
@@ -2009,13 +2014,6 @@ value.  Otherwise return CHILDREN as is."
 
 (defun transient--emergency-exit ()
   "Exit the current transient command after an error occurred.
-
-Beside being used with `condition-case', this function also has
-to be a member of `debugger-mode-hook', else the debugger would
-be unusable and exiting it by pressing \"q\" would fail because
-the transient command would still be active and that key would
-either be unbound or do something else.
-
 When no transient is active (i.e. when `transient--prefix') is
 nil, then do nothing."
   (transient--debug 'emergency-exit)
@@ -2025,8 +2023,6 @@ nil, then do nothing."
     (transient--pre-exit)
     (transient--post-command)))
 
-(add-hook 'debugger-mode-hook 'transient--emergency-exit)
-
 ;;; Pre-Commands
 
 (defun transient--do-stay ()



reply via email to

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