Subject: Re: bug#11567: 24.0.97; WTF? ROFL! (hilarious bug)

From: Troels Nielsen <[email-masked]>
Date: Mon, 28 May 2012 00:33:14 +0200

On Sun, May 27, 2012 at 4:59 PM, Tobias Bading <[email-masked]> wrote:
> Boys & girls, please *do* try this at home! (Or whereever your Emacs is :-). Works with r108017 of the emacs-24 branch on GNU/Linux as well as Mac OS for me.)
>
> emacs -Q:
> C-h v TAB C-x o C-x 0
>
> Your Emacs frame should now contain a single window with a completion list of variables.
> Take your pick: Select any variable either with your mouse, trackpad or keyboard.... Oooops! :-D

Well, it looks as though the *Completions* buffer only wants to be a
little thorough when hiding itself.

I don't really know the origin of the behavior, but I think it's
natural if there had been opened a special frame just for the
*Completions* buffer, so I suppose that's why it has been put there.

I propose the following patch, which does a little more checking if
it's likely that emacs has been opening a special frame for the
*Completions*-buffer. With some effort you could probably still get
emacs to iconify an unexpecting frame, but I don't think many people
would, if not for playing hide and seek that is... ;)

Regards
Troels

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-05-27 01:06:44 +0000
+++ lisp/ChangeLog	2012-05-27 22:18:53 +0000
@@ -1,3 +1,8 @@
+2012-05-27  Troels Nielsen <[email-masked]>
+
+	* simple.el (choose-completion): Be a little more particular
+	before iconifying a frame, when a completion has been chosen.
+
 2012-05-27  Eli Zaretskii  <[email-masked]>

 	* mail/sendmail.el (mail-yank-region): Recognize

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2012-05-04 23:16:47 +0000
+++ lisp/simple.el	2012-05-27 22:15:15 +0000
@@ -6214,7 +6215,11 @@
         (error "Destination buffer is dead"))
       (select-window (posn-window (event-start event)))
       (if (and (one-window-p t 'selected-frame)
-	       (window-dedicated-p (selected-window)))
+               (window-dedicated-p (selected-window))
+               (let ((buffer-name (buffer-name
+                                   (window-buffer (selected-window)))))
+                 (and (not (same-window-p buffer-name))
+                      (special-display-p buffer-name))))
 	  ;; This is a special buffer's frame
 	  (iconify-frame (selected-frame))
 	(or (window-dedicated-p (selected-window))