Subject: bug#79125: quit-window fails to restore window height in a scenario of buffer reuse

From: martin rudalics <[email-masked]>
Date: Thu, 31 Jul 2025 10:46:09 +0200

>> Do you have any ideas why 'resize-temp-buffer-window-inhibit' does not
 >> apply here?
 >
 > It seems 'resize-temp-buffer-window-inhibit' is not an user option
 > since 'window--display-buffer' changes its value.

I meant why 'window--display-buffer' would not have set it ...

 > But I meant
 > other cases since there is no auto-resizing in Dmitry's test case
 > while using these settings:
 >
 > (remove-hook 'vc-diff-finish-functions 'vc-shrink-buffer-window)
 > (remove-hook 'vc-log-finish-functions 'vc-shrink-buffer-window)

... which explains it, thanks.  So the resizing happens outside the
scope of 'display-buffer'.  We could rewrite 'vc-shrink-buffer-window'
as

(defun vc-shrink-buffer-window (&optional buffer)
   "Call `shrink-window-if-larger-than-buffer' only when BUFFER is visible.
BUFFER defaults to the current buffer."
   (let ((window (get-buffer-window buffer t)))
     (when window
       (let* ((quit-restore (window-parameter window 'quit-restore))
	     (quad (and quit-restore (nth 1 quit-restore))))
	(when (or (not quit-restore) (not (list quad))
		  (eq (window-buffer window) (nth 0 quad)))
	  (shrink-window-if-larger-than-buffer window))))))

but I'm not sure whether people will like it.

martin