Subject: Re: bug#36161: 27.0.50; display-buffer-in-previous-window might choose not to use PREVIOUS-WINDOW

From: martin rudalics <[email-masked]>
Date: Thu, 13 Jun 2019 10:43:56 +0200

>  > I would have to understand first why one and the same buffer was
 >  > displayed in different windows previously.
 >
 > Not sure what answer you're looking for. Suppose a user used switch-to-buffer sometime in the past to show it there?
 >
 > I think the question is, if the caller supplies the `previous-window' cons in ALIST, is there a point in second-guessing its choice?
 >
 > FWIW, I've only found one user of this function that does that, and it's `debug'. Which behavior do you think that command would prefer?

'display-buffer-in-previous-window' was added to fix a problem with
the debugger buffer (Bug#8789).  The idea behind it is that once a
buffer was shown in a specific window and that window still exists, it
would support the principle of least surprise to show it there again.
And to _not_ have this function do anything when a window showing that
buffer was just ephemeral and got deleted in between. In that latter
case a more deterministic function (like below-selected, at-bottom)
should take over.

'display-buffer-in-previous-window' will work well if it is
exclusively used for showing a buffer a second time (maybe together
with 'prev-buffer' and 'next-buffer').  It's behavior deteriorates as
soon as a user switches to that buffer in some arbitrary fashion.
Hence it's more suitable for buffers popping up in special occasions
(like, for example, when a bug occurred and the debugger should be
entered) and less suitable for buffer editing.

A 'previous-window' ALIST entry should continue to support the
principle of least surprise by allowing to choose a non-selected
window that never showed the buffer before.  The selected window,
however, should be always either chosen or excluded from choice by
special means - either via 'display-buffer-same-window' or using an
'inhibit-same-window' entry.

martin