Subject: Re: bug#17170: 24.3.50; debug: Terminal 3 is locked, cannot read from it

From: martin rudalics <[email-masked]>
Date: Sun, 22 Mar 2015 13:05:17 +0100

>> When it happens again please tell me the value of
 >> `debugger-previous-window'.  AFAICT this can only happen when that
 >> window was shown on the "initial frame F1" before.
 >
 > Yes it was a window on that frame (window 4 IIRC). I remember that
 > because this is the reason I did
 >      (setq debugger-previous-window (selected-window))
 > to bring the debugger back to my frame.

I can't understand what happened here because the only way to set
`debugger-previous-window' is via invoking `debug' and then doing
unconditionally

(setq debugger-window (selected-window))

followed by

(setq debugger-previous-window debugger-window))

so the window must have been the selected window when `debug' was called
the last time and Emacs should have complained then already.

Anyway.  I checked in a fix for Emacs 24.5 which should avoid this
problem now.  If you want to try it immediately please apply:

--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -192,7 +192,9 @@ first will be printed into the backtrace buffer."
  	       debugger-buffer
  	       `((display-buffer-reuse-window
  		  display-buffer-in-previous-window)
-		  . (,(when debugger-previous-window
+		 . (,(when (and (window-live-p debugger-previous-window)
+				(frame-visible-p
+				 (window-frame debugger-previous-window)))
  			`(previous-window . ,debugger-previous-window)))))
  	      (setq debugger-window (selected-window))
  	      (if (eq debugger-previous-window debugger-window)

martin