Subject: Re: bug#63455: 30.0.50; display-buffer-in-direction is always resizing

From: martin rudalics <[email-masked]>
Date: Fri, 12 May 2023 09:39:40 +0200

> 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.

I think you're right.  In my local Emacs I removed both incarnations of
that code (the other one being in 'display-buffer--maybe-at-bottom')
long ago.  I can only shortly sketch how I manage things here: The end
of 'help--window-setup' has become

         (help-window-setup
          (setq window (temp-buffer-window-show (current-buffer) nil t)))
         (help-make-xrefs (current-buffer))
	(when (and window temp-buffer-resize-mode)
           (let (resize-temp-buffer-window-inhibit)
             (resize-temp-buffer-window window)))))))

'temp-buffer-window-show' has a third argument NO-RESIZE and its last
lines are rewritten as

	(with-selected-window window
	  (run-hooks 'temp-buffer-window-show-hook)
	  (when (and (not no-resize) temp-buffer-resize-mode)
	    (resize-temp-buffer-window window)))
	;; Return the window.
	window))))

Maybe Juri can make heads or tails of this.

martin