Function: fit-frame-to-buffer

fit-frame-to-buffer is an interactive and byte-compiled function defined in window.el.gz.

Signature

(fit-frame-to-buffer &optional FRAME MAX-HEIGHT MIN-HEIGHT MAX-WIDTH MIN-WIDTH ONLY)

Documentation

Adjust size of FRAME to display the contents of its buffer exactly.

FRAME can be any live frame and defaults to the selected one. Fit only if FRAME's root window is live.

MAX-HEIGHT, MIN-HEIGHT, MAX-WIDTH and MIN-WIDTH specify bounds on the new total size of FRAME's root window. MIN-HEIGHT and MIN-WIDTH default to the values of window-min-height and window-min-width respectively. These arguments are specified in the canonical character width and height of FRAME.

If the optional argument ONLY is vertically, resize the frame vertically only. If ONLY is horizontally, resize the frame horizontally only.

The new position and size of FRAME can be additionally determined by customizing the options fit-frame-to-buffer-sizes and fit-frame-to-buffer-margins or setting the corresponding parameters of FRAME.

Any leading or trailing empty lines of the buffer content are not considered.

View in manual

Probably introduced at or before Emacs version 24.3.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun fit-frame-to-buffer (&optional frame max-height min-height max-width min-width only)
  "Adjust size of FRAME to display the contents of its buffer exactly.
FRAME can be any live frame and defaults to the selected one.
Fit only if FRAME's root window is live.

MAX-HEIGHT, MIN-HEIGHT, MAX-WIDTH and MIN-WIDTH specify bounds on
the new total size of FRAME's root window.  MIN-HEIGHT and
MIN-WIDTH default to the values of `window-min-height' and
`window-min-width' respectively.  These arguments are specified
in the canonical character width and height of FRAME.

If the optional argument ONLY is `vertically', resize the frame
vertically only.  If ONLY is `horizontally', resize the frame
horizontally only.

The new position and size of FRAME can be additionally determined
by customizing the options `fit-frame-to-buffer-sizes' and
`fit-frame-to-buffer-margins' or setting the corresponding
parameters of FRAME.

Any leading or trailing empty lines of the buffer content are not
considered."
  (interactive)
  (fit-frame-to-buffer-1 frame max-height min-height max-width min-width only t t))