Subject: bug#18181: bug in display-buffer-below-selected

From: martin rudalics <[email-masked]>
Date: Tue, 05 Aug 2014 10:36:09 +0200

>> This is the intended behavior
 >
 > OK.

I'm afraid you don't like it.  But let me explain why it's this way: As
a first step, `display-buffer' usually searches all windows whether the
buffer is already displayed.  This search doesn't come without any cost
because we have to check whether the selected window or another frame
are eligible.  Hence, it makes sense to do that search in the separate
action function `display-buffer-reuse-window'.  Usually, that function
is the very first tried by `display-buffer'.

The remaining action functions have been written based on the idea that
`display-buffer-reuse-window' already failed to find a suitable window
and either a new window or one that doesn't display the buffer already
has to be provided.

 > Just FYI however, there has been a change in behavior. It's possible that other software has been affected by the change. For example, the reason I used display-buffer-below-selected was because I saw it used in rmail.  You might want to make sure that rmail is still working correctly.

Can you elaborate how rmail might be affected by this?

 > I'm not sure how it corresponds to bzr but you can see the git commit here:
 >
 > http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=6a5d9e9a3247566bf69575444e2a1f75f5b3e021
 >
 > With that commit I see the new behavior.  Before that commit, all the way up to 24.3 at least, I see the old behavior.

I understand what you mean now.  That indeed changed the behavior for
the "frame has more than one window" case.  Though IIRC its intention
was to handle the case where the buffer is _not_ displayed yet, a fact
`display-buffer-reuse-window' should have implicitly checked before.

 > Also: I have to say that looking at the documentation it is hard to say what the intended behavior is.

As a rule: The idea is that an application should always try
`display-buffer-reuse-window' first unless the intended behavior is to
strictly use a new window or one that displays another buffer.  If you
(or anyone else) have any good ideas how to change the documentation
such that this idea becomes immediately evident, please don't hesitate
to propose the necessary change.  I have not written the present
documentation and my English probably isn't well enough to do the job.

Thanks, martin