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.

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.

This function may call preserve-window-size to preserve the size of WINDOW.

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'.

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.

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)
		    (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))))
    ;; 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))
		       (and (window-combined-p window t)
			    fit-window-to-buffer-horizontally)))
	      (and (eq quit-cadr 'frame)
                   fit-frame-to-buffer
                   (eq window (frame-root-window window))))
	(fit-window-to-buffer window height nil width nil t))))