Subject: bug#17882: 24.3; *Backtrace* buffer appearing in the wrong frame

From: Noam Postavsky <[email-masked]>
Date: Thu, 12 Oct 2017 23:02:05 -0400

tags 17882 + patch
quit

Michael Heerdegen <[email-masked]> writes:

> I think the debugger is now too strict about reusing the last used
> window.  `debug` prefers the remembered `debugger-previous-window`.
> AFAIK, this variable is never unset, so the debugger tries to reuse the
> last used window even when the last debugging session was over for
> hours.

How about just unsetting the debugger-previous-window when the session
is over, we already know this info from the `debugger-will-be-back'
variable:

>From bdeae0b9afcccc11d43d46089ea4648a68b709cd Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Thu, 12 Oct 2017 22:59:53 -0400
Subject: [PATCH v1] Don't remember old debugger window (Bug#17882)

* lisp/emacs-lisp/debug.el (debug): Unset debugger-previous-window
when `debugger-will-be-back' is nil.
---
 lisp/emacs-lisp/debug.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 0247179a84..6c754615b0 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -253,7 +253,9 @@ debug
 		;; Unshow debugger-buffer.
 		(quit-restore-window debugger-window debugger-bury-or-kill)
 		;; Restore current buffer (Bug#12502).
-		(set-buffer debugger-old-buffer))))
+		(set-buffer debugger-old-buffer)))
+            ;; Forget debugger window, it won't be back (Bug#17882).
+            (setq debugger-previous-window nil))
           ;; Restore previous state of debugger-buffer in case we were
           ;; in a recursive invocation of the debugger, otherwise just
           ;; erase the buffer and put it into fundamental mode.
-- 
2.11.0