diff --git a/lisp/help.el b/lisp/help.el index 29ae340481..b67b5a4237 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1589,6 +1589,16 @@ temp-buffer-resize-mode (add-hook 'temp-buffer-show-hook 'resize-temp-buffer-window 'append) (remove-hook 'temp-buffer-show-hook 'resize-temp-buffer-window))) +(defun resize-temp-buffer-window-inhibit (buffer &optional horizontal) + "Return non-nil if windows on BUFFER should not be resized automatically. +`resize-temp-buffer-window' calls this function to check whether +`display-buffer-alist' contains a setting that inhibits +auto-resizing of any window showing BUFFER." + (assq + (if horizontal 'window-width 'window-height) + (display-buffer-assq-regexp + (buffer-name buffer) display-buffer-alist nil))) + (defun resize-temp-buffer-window (&optional window) "Resize WINDOW to fit its contents. WINDOW must be a live window and defaults to the selected one. @@ -1607,26 +1617,33 @@ resize-temp-buffer-window This function may call `preserve-window-size' to preserve the size of WINDOW." (setq window (window-normalize-window window t)) - (let ((height (if (functionp temp-buffer-max-height) + (let* ((buffer (window-buffer window)) + (height (if (functionp temp-buffer-max-height) + (with-selected-window window + (funcall temp-buffer-max-height buffer)) + temp-buffer-max-height)) + (width (if (functionp temp-buffer-max-width) (with-selected-window window - (funcall temp-buffer-max-height (window-buffer))) - temp-buffer-max-height)) - (width (if (functionp temp-buffer-max-width) - (with-selected-window window - (funcall temp-buffer-max-width (window-buffer))) - temp-buffer-max-width)) - (quit-cadr (cadr (window-parameter window 'quit-restore)))) + (funcall temp-buffer-max-width buffer)) + temp-buffer-max-width)) + (quit-cadr (cadr (window-parameter window 'quit-restore)))) ;; Resize WINDOW iff it was made by `display-buffer'. (when (or (and (eq quit-cadr 'window) (or (and (window-combined-p window) (not (eq fit-window-to-buffer-horizontally 'only)) - (pos-visible-in-window-p (point-min) window)) + (pos-visible-in-window-p + (with-current-buffer buffer (point-min)) + window) + (not (resize-temp-buffer-window-inhibit buffer))) (and (window-combined-p window t) - fit-window-to-buffer-horizontally))) + fit-window-to-buffer-horizontally + (not (resize-temp-buffer-window-inhibit buffer t))))) (and (eq quit-cadr 'frame) fit-frame-to-buffer - (eq window (frame-root-window window)))) + (eq window (frame-root-window window)) + (not (resize-temp-buffer-window-inhibit buffer)) + (not (resize-temp-buffer-window-inhibit buffer t)))) (fit-window-to-buffer window height nil width nil t)))) ;;; Help windows.