Subject: bug#55863: 29.0.50; [PATCH] Avoid hanging chad of *Backtrace*

From: Juri Linkov <[email-masked]>
Date: Thu, 09 Jun 2022 20:58:39 +0300

>> A better question is why *Backtrace* is erased?
>> Often I accidentally quit the backtrace, then
>> try to switch to the *Backtrace* buffer to check
>> the backtrace again, but to no avail.
>
> I don't think you can usefully interact with it after exiting the
> recursive edit?  That is, I think all the stuff that's bound in the
> `debug' command (debugger-outer-match-data etc etc) has to continue to
> be bound...
>
> But perhaps that can be fixed?

I have no idea what will happen when it's not erased, need to try.
Hmm, interesting, after this all backtrace links are still valid:

diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 6c172d6c31..eb71b12341 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -308,13 +308,13 @@ debug
             ;; Restore previous state of debugger-buffer in case we were
             ;; in a recursive invocation of the debugger, otherwise just
             ;; erase the buffer.
-	    (when (buffer-live-p debugger-buffer)
-	      (with-current-buffer debugger-buffer
-	        (if debugger-previous-state
-                    (debugger--restore-buffer-state debugger-previous-state)
-                  (setq backtrace-insert-header-function nil)
-                  (setq backtrace-frames nil)
-                  (backtrace-print))))
+            ;; (when (buffer-live-p debugger-buffer)
+            ;;   (with-current-buffer debugger-buffer
+            ;;     (if debugger-previous-state
+            ;;         (debugger--restore-buffer-state debugger-previous-state)
+            ;;       (setq backtrace-insert-header-function nil)
+            ;;       (setq backtrace-frames nil)
+            ;;       (backtrace-print))))
 	    (with-timeout-unsuspend debugger-with-timeout-suspend)
 	    (set-match-data debugger-outer-match-data)))
         (setq debug-on-next-call debugger-step-after-exit)