Subject: Re: bug#32790: 27.0.50; point jumps unexpectedly after delete-window

From: Juri Linkov <[email-masked]>
Date: Mon, 05 Nov 2018 00:01:25 +0200

>> Yes, killing the buffer without deleting its window will display
>> some random buffer in its place - this is bad.
>
> We could display a buffer that was previously shown in that window if
> there is one.  But I think that such a buffer might be there just due
> to a temporary excursion so I don't think it's a good idea.

Actually there is some problem with the third argument 'window' of
window--display-buffer:

0. emacs -Q

1. C-h e
   displays *Messages* in another window

2. in *scratch* eval:

   (window--display-buffer (get-buffer-create "test1") (next-window) 'window)

   displays "test1" in the window where *Messages* was displayed

3. C-x o
   select the window with "test1"

4. M-: (quit-window 1)
   the window is deleted.

I'd expect that it shouldn't delete the window, but should restore the
buffer previously displayed in that window, i.e. the *Messages* buffer,
because this is what quit-window does when the "test1" buffer was created
manually with e.g. 'C-x b test1'.