fit-window-to-buffer
fit-window-to-buffer is an interactive compiled Lisp function in `window.el
'.
(fit-window-to-buffer &optional WINDOW MAX-HEIGHT MIN-HEIGHT MAX-WIDTH MIN-WIDTH PRESERVE-SIZE)
Adjust size of WINDOW to display its buffer's contents exactly.
WINDOW must be a live window and defaults to the selected one.
If WINDOW is part of a vertical combination, adjust WINDOW's
height. The new height is calculated from the actual height of
the accessible portion of its buffer. The optional argument
MAX-HEIGHT specifies a maximum height and defaults to the height
of WINDOW's frame. The optional argument MIN-HEIGHT specifies a
minimum height and defaults to `window-min-height'. Both
MAX-HEIGHT and MIN-HEIGHT are specified in lines and include mode
and header line and a bottom divider, if any.
If WINDOW is part of a horizontal combination and the value of
the option `fit-window-to-buffer-horizontally' is non-nil, adjust
WINDOW's width. The new width of WINDOW is calculated from the
maximum length of its buffer's lines that follow the current
start position of WINDOW. The optional argument MAX-WIDTH
specifies a maximum width and defaults to the width of WINDOW's
frame. The optional argument MIN-WIDTH specifies a minimum width
and defaults to `window-min-width'. Both MAX-WIDTH and MIN-WIDTH
are specified in columns and include fringes, margins, a
scrollbar and a vertical divider, if any.
If the optional argument `preserve-size' is non-nil, preserve the
size of WINDOW (see `window-preserve-size').
Fit pixelwise if the option `window-resize-pixelwise' is non-nil.
If WINDOW is its frame's root window and the option
`fit-frame-to-buffer' is non-nil, call `fit-frame-to-buffer' to
adjust the frame's size.
Note that even if this function makes WINDOW large enough to show
_all_ parts of its buffer you might not see the first part when
WINDOW was scrolled. If WINDOW is resized horizontally, you will
not see the top of its buffer unless WINDOW starts at its minimum
accessible position.