Subject: bug#7533: 24.0.50; `dired-mark-pop-up': delete frame afterwards if `pop-up-frames'

From: martin rudalics <[email-masked]>
Date: Fri, 03 Dec 2010 09:17:54 +0100

> Agreed.  But what's the right test?  It is _not_ `pop-up-frames' non-nil,
 > because users can do other things than that to cause a new frame to be created
 > for this dialog.  What's needed is a test of whether a frame was newly created
 > for this dialog buffer.  What's the code for that test?

In the past, routines usually tested the settings of variables like
`pop-up-windows' or `pop-up-frames' to guess the expected behavior of
`display-buffer'.  In most cases the guesses were correct.  In a few
corner cases they failed and the example you cite above is one of them.

Here I have two things: A window parameter that tells for each window
whether the current buffer is the first buffer shown in it and a
separate global variable which gives some rudimentary information about
what the last `display-buffer' invocation did to find a suitable window.
The former exists independently of `display-buffer' so it also works for
a "manually" constructed or reused window or frame.  The latter is
`display-buffer' specific and is mainly used for providing some feedback
about the change of the entire window configuration.

 >> BTW the `save-window-excursion' is completely useless when
 >> you pop up a new frame.
 >
 > Yes, I know.  It was already there, and I left it.  It seems benign in this case
 > AFAICT, but feel free to fix this as it really should be fixed.

`save-window-excursion' is hardly ever benign.  Whenever you find a
`display-buffer' wrapped in a `save-window-excursion' you can be 100%
sure that the code fails with popped up frames.

 > The bug report is about the annoyance of not deleting a new frame that was
 > created (using whatever mechanism, including non-nil `pop-up-frames') for dialog
 > purposes.  When the dialog is finished, such a new frame should disappear.
 > Users should not need to manually delete it.

There's no formal definition of "dialog purpose" in Emacs and it's not
easy to do that in general.  The major problem to address is whether and
how such a dialog can be disrupted by other activities and how to resume
it at a later time.

martin