Subject: 30.0.50; display-buffer-in-direction is always resizing

From: Michael Heerdegen <[email-masked]>
Date: Fri, 12 May 2023 03:06:07 +0200

X-Debbugs-CC: [email-masked], [email-masked], [email-masked]

Hello,

(info "(elisp) Buffer Display Action Alists") says near the end:

|    If no ‘window-height’, ‘window-width’ or ‘window-size’ entry was
| specified, the window may still be resized automatically when the buffer
| is temporary and ‘temp-buffer-resize-mode’ has been enabled, *note
| Temporary Displays::.  In that case, the CDR of a ‘window-height’,
| ‘window-width’ or ‘window-size’ entry can be used to inhibit or override
| the default behavior of ‘temp-buffer-resize-mode’ for specific buffers
| or invocations of ‘display-buffer’.

OTOH, the action `display-buffer-in-direction' _always_ resizes the
window no matter what buffer is current.  Try e.g.

#+begin_src emacs-lisp
(display-buffer (current-buffer)
               '((display-buffer-in-direction) . ((direction . top))))
#+end_src

from any window or buffer.

This is handled by this part of the implementation of
`display-buffer-in-direction':

#+begin_src emacs-lisp
	(setq alist
	      (append alist
		      `(,(if temp-buffer-resize-mode
		             '(window-height . resize-temp-buffer-window)
	                   '(window-height . fit-window-to-buffer))
	                ,(when temp-buffer-resize-mode
	                   '(preserve-size . (nil . t))))))
#+end_src

Looking at that it doesn't seem to be intended as a general behavior,
and the behavior is not a good default IMO - even if it can be
suppressed by adding a (window-height . nil) entry to the
`display-buffer' call.

I guess that Bug#45945 could be a symptom of this problem.

TIA,

Michael.