From 19a7d4ce7c6b075f2ff5d98f3e8c5c0e8e4a61cd Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 12 Jun 2026 09:44:01 +0200 Subject: [PATCH] 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). --- lisp/help.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/help.el b/lisp/help.el index f5fe34435bb..b5eba8707db 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -2003,10 +2003,8 @@ show a temporary buffer are automatically resized in height to fit the buffer's contents, but never more than `temp-buffer-max-height' nor less than `window-min-height'. -A window is resized only if it has been specially created for the -buffer. Windows that have shown another buffer before are not -resized. A frame is resized only if `fit-frame-to-buffer' is -non-nil. +A window is resized only if it has been specially created for its +buffer. A frame is resized only if `fit-frame-to-buffer' is non-nil. This mode is used by `help', `apropos' and `completion' buffers, and some others." @@ -2050,7 +2048,10 @@ provided `fit-frame-to-buffer' is non-nil." (quit-cadr (cadr (window-parameter window 'quit-restore)))) ;; Resize WINDOW only if it was made by `display-buffer'. (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 'only)) (pos-visible-in-window-p