Subject: Re: bug#12764: 24.2; `quit-window' wrongly iconifies frame

From: Chong Yidong <[email-masked]>
Date: Tue, 30 Oct 2012 11:26:32 +0800

Romain Francoise <[email-masked]> writes:

> There's a regression in Emacs 24 compared to Emacs 23 wrt the behavior
> of `quit-window'. In some circumstances, it iconifies frames that were
> existing before the current buffer was created, which (AIUI) it's not
> supposed to do.
>
> Recipe starting from `emacs -Q':
> - C-x 5 2 to create a new frame
> - in the new frame, M-x man RET emacs RET
> - C-x 0 to make the man buffer the current buffer
> - q
>
> When you hit `q' the frame gets iconified, even though it was not
> created by M-x man.

I think the attached patch is required to fix this.  Martin, please
review, thanks.

=== modified file 'lisp/window.el'
*** lisp/window.el	2012-10-27 08:58:30 +0000
--- lisp/window.el	2012-10-30 03:23:59 +0000
***************
*** 3556,3562 ****
  	 quad entry)
      (cond
       ((and (not prev-buffer)
! 	   (memq (nth 1 quit-restore) '(window frame))
  	   (eq (nth 3 quit-restore) buffer)
  	   ;; Delete WINDOW if possible.
  	   (window--delete window nil (eq bury-or-kill 'kill)))
--- 3556,3566 ----
  	 quad entry)
      (cond
       ((and (not prev-buffer)
! 	   (or (eq (nth 1 quit-restore) 'frame)
! 	       ;; If the window had been created on an existing frame,
! 	       ;; do not try to delete the frame.
! 	       (and (eq (nth 1 quit-restore) 'window)
! 		    (not (eq (window-deletable-p window) 'frame))))
  	   (eq (nth 3 quit-restore) buffer)
  	   ;; Delete WINDOW if possible.
  	   (window--delete window nil (eq bury-or-kill 'kill)))