Function: resize-temp-buffer-window
resize-temp-buffer-window is a byte-compiled function defined in
help.el.gz.
Signature
(resize-temp-buffer-window &optional WINDOW)
Documentation
Resize WINDOW to fit its contents.
WINDOW must be a live window and defaults to the selected one.
Do not resize if WINDOW was not created by display-buffer. Do
not resize either if a window-height, window-width or
window-size entry in display-buffer-alist prescribes some
alternative resizing for WINDOW's buffer.
If WINDOW is part of a vertical combination, restrain its new
size by temp-buffer-max-height and do not resize if its minimum
accessible position is scrolled out of view. If WINDOW is part
of a horizontal combination, restrain its new size by
temp-buffer-max-width. In both cases, the value of the option
fit-window-to-buffer-horizontally can inhibit resizing.
If WINDOW is the root window of its frame, resize the frame
provided fit-frame-to-buffer(var)/fit-frame-to-buffer(fun) is non-nil.
Source Code
;; Defined in /usr/src/emacs/lisp/help.el.gz
(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.
Do not resize if WINDOW was not created by `display-buffer'. Do
not resize either if a `window-height', `window-width' or
`window-size' entry in `display-buffer-alist' prescribes some
alternative resizing for WINDOW's buffer.
If WINDOW is part of a vertical combination, restrain its new
size by `temp-buffer-max-height' and do not resize if its minimum
accessible position is scrolled out of view. If WINDOW is part
of a horizontal combination, restrain its new size by
`temp-buffer-max-width'. In both cases, the value of the option
`fit-window-to-buffer-horizontally' can inhibit resizing.
If WINDOW is the root window of its frame, resize the frame
provided `fit-frame-to-buffer' is non-nil."
(setq window (window-normalize-window window t))
(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-width buffer))
temp-buffer-max-width))
(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)
(not (eq fit-window-to-buffer-horizontally
'only))
(pos-visible-in-window-p
(with-current-buffer buffer (point-min))
window)
(not resize-temp-buffer-window-inhibit))
(and (window-combined-p window t)
fit-window-to-buffer-horizontally
(not resize-temp-buffer-window-inhibit))))
(and (eq quit-cadr 'frame)
fit-frame-to-buffer
(eq window (frame-root-window window))
(not resize-temp-buffer-window-inhibit)))
(fit-window-to-buffer window height nil width nil t))))