Function: window-preserve-size
window-preserve-size is a byte-compiled function defined in
window.el.gz.
Signature
(window-preserve-size &optional WINDOW HORIZONTAL PRESERVE)
Documentation
Preserve height of specified WINDOW's body.
WINDOW must be a live window and defaults to the selected one. Optional argument HORIZONTAL non-nil means to preserve the width of WINDOW's body.
PRESERVE t means to preserve the current height/width of WINDOW's body in frame and window resizing operations whenever possible. The height/width of WINDOW will change only if Emacs has no other choice. Resizing a window whose height/width is preserved never throws an error.
PRESERVE nil means to stop preserving the height/width of WINDOW,
lifting the respective restraint induced by a previous call of
window-preserve-size for WINDOW. Calling enlarge-window,
shrink-window, split-window or fit-window-to-buffer with
WINDOW as argument also removes the respective restraint.
Other values of PRESERVE are reserved for future use.
Probably introduced at or before Emacs version 25.1.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window-preserve-size (&optional window horizontal preserve)
"Preserve height of specified WINDOW's body.
WINDOW must be a live window and defaults to the selected one.
Optional argument HORIZONTAL non-nil means to preserve the width
of WINDOW's body.
PRESERVE t means to preserve the current height/width of WINDOW's
body in frame and window resizing operations whenever possible.
The height/width of WINDOW will change only if Emacs has no other
choice. Resizing a window whose height/width is preserved never
throws an error.
PRESERVE nil means to stop preserving the height/width of WINDOW,
lifting the respective restraint induced by a previous call of
`window-preserve-size' for WINDOW. Calling `enlarge-window',
`shrink-window', `split-window' or `fit-window-to-buffer' with
WINDOW as argument also removes the respective restraint.
Other values of PRESERVE are reserved for future use."
(setq window (window-normalize-window window t))
(let* ((parameter (window-parameter window 'window-preserved-size))
(width (if horizontal
(and preserve (window-body-width window t))
(nth 1 parameter)))
(height (if horizontal
(nth 2 parameter)
(and preserve (window-body-height window t)))))
(set-window-parameter
window 'window-preserved-size
(list (window-buffer window) width height))))