Function: window-state-get

window-state-get is a byte-compiled function defined in window.el.gz.

Signature

(window-state-get &optional WINDOW WRITABLE)

Documentation

Return state of WINDOW as a Lisp object.

WINDOW can be any window and defaults to the root window of the selected frame.

Optional argument WRITABLE non-nil means do not use markers for sampling window-point and window-start. Together, WRITABLE and the variable window-persistent-parameters specify which parameters of WINDOW to save. By default, this is the clone-of parameter if WRITABLE is nil. WRITABLE should be non-nil when the return value shall be written to a file and read back in another session. Otherwise, an application may run into an invalid-read-syntax error while attempting to read back the value from file.

The return value can be used as argument for window-state-put to put the state recorded here into an arbitrary window. The value can be also stored on disk and read back in a new session.

View in manual

Probably introduced at or before Emacs version 24.1.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window-state-get (&optional window writable)
  "Return state of WINDOW as a Lisp object.
WINDOW can be any window and defaults to the root window of the
selected frame.

Optional argument WRITABLE non-nil means do not use markers for sampling
`window-point' and `window-start'.  Together, WRITABLE and the variable
`window-persistent-parameters' specify which parameters of WINDOW to
save.  By default, this is the `clone-of' parameter if WRITABLE is nil.
WRITABLE should be non-nil when the return value shall be written to a
file and read back in another session.  Otherwise, an application may
run into an `invalid-read-syntax' error while attempting to read back
the value from file.

The return value can be used as argument for `window-state-put'
to put the state recorded here into an arbitrary window.  The
value can be also stored on disk and read back in a new session."
  (setq window
	(if window
	    (if (window-valid-p window)
		window
	      (error "%s is not a live or internal window" window))
	  (frame-root-window)))
  ;; The return value is a cons whose car specifies some constraints on
  ;; the size of WINDOW.  The cdr lists the states of the child windows
  ;; of WINDOW.
  (cons
   ;; Frame related things would go into a function, say `frame-state',
   ;; calling `window-state-get' to insert the frame's root window.
   `((min-height        . ,(window-min-size window))
     (min-width         . ,(window-min-size window t))
     (min-height-ignore . ,(window-min-size window nil t))
     (min-width-ignore  . ,(window-min-size window t t))
     (min-height-safe   . ,(window-min-size window nil 'safe))
     (min-width-safe    . ,(window-min-size window t 'safe))
     (min-pixel-height  . ,(window-min-size window nil nil t))
     (min-pixel-width   . ,(window-min-size window t nil t))
     (min-pixel-height-ignore . ,(window-min-size window nil t t))
     (min-pixel-width-ignore  . ,(window-min-size window t t t))
     (min-pixel-height-safe   . ,(window-min-size window nil 'safe t))
     (min-pixel-width-safe    . ,(window-min-size window t 'safe t)))
   (window--state-get-1 window writable)))