Function: window--state-get-1
window--state-get-1 is a byte-compiled function defined in
window.el.gz.
Signature
(window--state-get-1 WINDOW &optional WRITABLE)
Documentation
Helper function for window-state-get.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--state-get-1 (window &optional writable)
"Helper function for `window-state-get'."
(let* ((type
(cond
((window-top-child window) 'vc)
((window-left-child window) 'hc)
(t 'leaf)))
(buffer (window-buffer window))
(selected (eq window (selected-window)))
(next-buffers (when (window-live-p window)
(delq nil (mapcar (lambda (buffer)
(and (buffer-live-p buffer) buffer))
(window-next-buffers window)))))
(prev-buffers (when (window-live-p window)
(delq nil (mapcar (lambda (entry)
(and (buffer-live-p (nth 0 entry))
entry))
(window-prev-buffers window)))))
(head
`(,type
,@(unless (window-next-sibling window) '((last . t)))
(pixel-width . ,(window-pixel-width window))
(pixel-height . ,(window-pixel-height window))
(total-width . ,(window-total-width window))
(total-height . ,(window-total-height window))
(normal-height . ,(window-normal-size window))
(normal-width . ,(window-normal-size window t))
,@(unless (window-live-p window)
`((combination-limit . ,(window-combination-limit window))))
,@(let ((parameters (window-parameters window))
list)
;; Make copies of those window parameters whose
;; persistence property is `writable' if WRITABLE is
;; non-nil and non-nil if WRITABLE is nil.
(dolist (par parameters)
(let ((pers (cdr (assq (car par)
window-persistent-parameters))))
(when (and pers (or (not writable) (eq pers 'writable)))
(setq list (cons (cons (car par) (cdr par)) list)))))
;; Add `clone-of' parameter if necessary.
(let ((pers (cdr (assq 'clone-of
window-persistent-parameters))))
(when (and pers (or (not writable) (eq pers 'writable))
(not (assq 'clone-of list)))
(setq list (cons (cons 'clone-of window) list))))
(when list
`((parameters . ,list))))
,@(when buffer
;; All buffer related things go in here.
(let ((point (window-point window))
(start (window-start window)))
`((buffer
,(if writable (window--state-normalize-buffer-name
buffer) buffer)
(selected . ,selected)
(hscroll . ,(window-hscroll window))
(fringes . ,(window-fringes window))
(margins . ,(window-margins window))
(scroll-bars . ,(window-scroll-bars window))
(vscroll . ,(window-vscroll window))
(dedicated . ,(window-dedicated-p window))
(point . ,(if writable
point
(with-current-buffer buffer
(copy-marker point
(buffer-local-value
'window-point-insertion-type
buffer)))))
(start . ,(if writable
start
(with-current-buffer buffer
(copy-marker start))))))))
,@(when next-buffers
`((next-buffers
. ,(if writable
(mapcar #'window--state-normalize-buffer-name
next-buffers)
next-buffers))))
,@(when prev-buffers
`((prev-buffers
. ,(if writable
(mapcar (lambda (entry)
(list (window--state-normalize-buffer-name
(nth 0 entry))
(marker-position (nth 1 entry))
(marker-position (nth 2 entry))))
prev-buffers)
prev-buffers))))))
(tail
(when (memq type '(vc hc))
(let (list)
(setq window (window-child window))
(while window
(setq list (cons (window--state-get-1 window writable) list))
(setq window (window-right window)))
(nreverse list)))))
(append head tail)))