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 window WINDOW.

WINDOW must be a live window and defaults to the selected one. Optional argument HORIZONTAL non-nil means preserve the width of WINDOW.

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 window WINDOW.
WINDOW must be a live window and defaults to the selected one.
Optional argument HORIZONTAL non-nil means preserve the width of
WINDOW.

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 (nth 1 parameter))
	 (height (nth 2 parameter)))
    (if horizontal
	(set-window-parameter
	 window 'window-preserved-size
	 (list
	  (window-buffer window)
	  (and preserve (window--preservable-size window t))
	  height))
      (set-window-parameter
       window 'window-preserved-size
       (list
	(window-buffer window)
	width
	(and preserve (window--preservable-size window)))))))