Function: window--state-put-2
window--state-put-2 is a byte-compiled function defined in
window.el.gz.
Signature
(window--state-put-2 IGNORE PIXELWISE)
Documentation
Helper function for window-state-put.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--state-put-2 (ignore pixelwise)
"Helper function for `window-state-put'."
(dolist (item window-state-put-list)
(let ((window (car item))
(combination-limit (cdr (assq 'combination-limit item)))
(parameters (cdr (assq 'parameters item)))
(state (cdr (assq 'buffer item)))
(next-buffers (cdr (assq 'next-buffers item)))
(prev-buffers (cdr (assq 'prev-buffers item))))
(when combination-limit
(set-window-combination-limit window combination-limit))
;; Reset window's parameters and assign saved ones (we might want
;; a `remove-window-parameters' function here).
(dolist (parameter (window-parameters window))
(set-window-parameter window (car parameter) nil))
(when parameters
(dolist (parameter parameters)
(set-window-parameter window (car parameter) (cdr parameter))))
;; Process buffer related state.
(when state
(let ((buffer (get-buffer (car state)))
(state (cdr state)))
(if buffer
(with-current-buffer buffer
(set-window-buffer window buffer)
(set-window-hscroll window (cdr (assq 'hscroll state)))
(apply 'set-window-fringes
(cons window (cdr (assq 'fringes state))))
(let ((margins (cdr (assq 'margins state))))
(set-window-margins window (car margins) (cdr margins)))
(let ((scroll-bars (cdr (assq 'scroll-bars state))))
(set-window-scroll-bars
window (car scroll-bars) (nth 2 scroll-bars)
(nth 3 scroll-bars) (nth 5 scroll-bars) (nth 6 scroll-bars)))
(set-window-vscroll window (cdr (assq 'vscroll state)))
;; Adjust vertically.
(if (or (memq window-size-fixed '(t height))
(window-preserved-size window))
;; A fixed height window, try to restore the
;; original size.
(let ((delta
(- (cdr (assq
(if pixelwise 'pixel-height 'total-height)
item))
(window-size window nil pixelwise)))
window-size-fixed)
(when (window--resizable-p
window delta nil nil nil nil nil pixelwise)
(window-resize window delta nil nil pixelwise)))
;; Else check whether the window is not high enough.
(let* ((min-size
(window-min-size window nil ignore pixelwise))
(delta
(- min-size (window-size window nil pixelwise))))
(when (and (> delta 0)
(window--resizable-p
window delta nil ignore nil nil nil pixelwise))
(window-resize window delta nil ignore pixelwise))))
;; Adjust horizontally.
(if (or (memq window-size-fixed '(t width))
(window-preserved-size window t))
;; A fixed width window, try to restore the original
;; size.
(let ((delta
(- (cdr (assq
(if pixelwise 'pixel-width 'total-width)
item))
(window-size window t pixelwise)))
window-size-fixed)
(when (window--resizable-p
window delta t nil nil nil nil pixelwise)
(window-resize window delta t nil pixelwise)))
;; Else check whether the window is not wide enough.
(let* ((min-size (window-min-size window t ignore pixelwise))
(delta (- min-size (window-size window t pixelwise))))
(when (and (> delta 0)
(window--resizable-p
window delta t ignore nil nil nil pixelwise))
(window-resize window delta t ignore pixelwise))))
;; Set dedicated status.
(set-window-dedicated-p window (cdr (assq 'dedicated state)))
;; Install positions (maybe we should do this after all
;; windows have been created and sized).
(ignore-errors
;; Set 'noforce argument to avoid that window start
;; overrides window point set below (Bug#24240).
(set-window-start window (cdr (assq 'start state)) 'noforce)
(set-window-point window (cdr (assq 'point state))))
;; Select window if it's the selected one.
(when (cdr (assq 'selected state))
(select-window window))
(set-window-next-buffers
window
(delq nil (mapcar (lambda (buffer)
(setq buffer (get-buffer buffer))
(when (buffer-live-p buffer) buffer))
next-buffers)))
(set-window-prev-buffers
window
(delq nil (mapcar (lambda (entry)
(let ((buffer (get-buffer (nth 0 entry)))
(m1 (nth 1 entry))
(m2 (nth 2 entry)))
(when (buffer-live-p buffer)
(list buffer
(if (markerp m1) m1
(set-marker (make-marker) m1
buffer))
(if (markerp m2) m2
(set-marker (make-marker) m2
buffer))))))
prev-buffers))))
;; We don't want to raise an error in case the buffer does
;; not exist anymore, so we switch to a previous one and
;; save the window with the intention of deleting it later
;; if possible.
(switch-to-prev-buffer window)
(push window window-state-put-stale-windows)))))))