Subject: bug#32825: 27.0.50; Deterministic window management

From: Juri Linkov <[email-masked]>
Date: Thu, 08 Nov 2018 23:58:20 +0200

>> I only added display-buffer-below-selected to pop-to-buffer
>> of "*Backtrace*" after display-buffer-in-previous-window,
>> and in `emacs -Q` with 3 windows where the bottom window is
>> very low, subsequent errors are displayed in different windows.
>
> Like this
>
> 	      (pop-to-buffer
> 	       debugger-buffer
> 	       `((display-buffer-reuse-window
> 		  display-buffer-in-previous-window
>                   display-buffer-below-selected)
> 		 . (,(when (and (window-live-p debugger-previous-window)
> 				(frame-visible-p
> 				 (window-frame debugger-previous-window)))
> 		       `(previous-window . ,debugger-previous-window)))))

Exactly.

> I presume.  This will, in the first invocation, make a new window below
> the selected one or reuse such a window because there is no previous
> window.  Later on, that window gets reused here as expected,
> regardless of whether the frame is wide or not.  With emacs -Q, at
> least.  Maybe you have additional customizations or changes at work?

With emacs -Q and without additional customizations, every error
(e.g. evaluating a non-existent variable) is shown in a different window
(first in 1, then in 2, then again in 1):

+---------------------+
| 1.                  |
|                     |
+---------------------+
| 2.                  |
|                     |
+---------------------+
| low selected window |
+---------------------+

This bug can be avoided by adding display-buffer-at-bottom
after display-buffer-below-selected, i.e. by using such actions:

display-buffer-reuse-window
display-buffer-in-previous-window
display-buffer-below-selected
display-buffer-at-bottom

This provides a nicer behavior because display-buffer-at-bottom tries
to resize other windows to accommodate the *Backtrace*.