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

From: Dmitry Gutov <[email-masked]>
Date: Fri, 1 Aug 2025 03:45:11 +0300

On 31/07/2025 11:46, martin rudalics wrote:
> (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))

I think you meant 'listp' here.

>            (eq (window-buffer window) (nth 0 quad)))
>        (shrink-window-if-larger-than-buffer window))))))

I've tried it out, and it doesn't seem to fix the original scenario.

If the goal was to implement your explanation from the other subthread:

 > In the following cases:
 >
 > - The window is new.
 >
 > - The window was already in use for this buffer.

...then it seems fail because it resizes an existing window showing a 
different buffer. Probably because the value of QUAD is 'window', in my 
testing.