Fix behavior of 'temp-buffer-resize-mode' (Bug#81207)

* lisp/help.el (temp-buffer-resize-mode): Fix doc-string - a
window can be resized now even if it has shown another buffer in
between (Bug#81207).
(resize-temp-buffer-window): Resize window if and only if its
buffer is the buffer it has shown initially (Bug#81207).
This commit is contained in:
Martin Rudalics 2026-06-12 09:44:01 +02:00
parent 927a7fff5e
commit 19a7d4ce7c

View file

@ -2003,10 +2003,8 @@ show a temporary buffer are automatically resized in height to
fit the buffer's contents, but never more than fit the buffer's contents, but never more than
`temp-buffer-max-height' nor less than `window-min-height'. `temp-buffer-max-height' nor less than `window-min-height'.
A window is resized only if it has been specially created for the A window is resized only if it has been specially created for its
buffer. Windows that have shown another buffer before are not buffer. A frame is resized only if `fit-frame-to-buffer' is non-nil.
resized. A frame is resized only if `fit-frame-to-buffer' is
non-nil.
This mode is used by `help', `apropos' and `completion' buffers, This mode is used by `help', `apropos' and `completion' buffers,
and some others." and some others."
@ -2050,7 +2048,10 @@ provided `fit-frame-to-buffer' is non-nil."
(quit-cadr (cadr (window-parameter window 'quit-restore)))) (quit-cadr (cadr (window-parameter window 'quit-restore))))
;; Resize WINDOW only if it was made by `display-buffer'. ;; Resize WINDOW only if it was made by `display-buffer'.
(when (or (and (eq quit-cadr 'window) (when (or (and (eq quit-cadr 'window)
(or (and (window-combined-p window) ;; When WINDOW was reused, its buffer must be the one
;; initially shown in it (Bug#81207).
(eq buffer (nth 3 (window-parameter window 'quit-restore)))
(or (and (window-combined-p window)
(not (eq fit-window-to-buffer-horizontally (not (eq fit-window-to-buffer-horizontally
'only)) 'only))
(pos-visible-in-window-p (pos-visible-in-window-p