(set-window-parameter window (car parameter) (cdr parameter))))
;; Process buffer related state.
(when state
- ;; 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.
(let ((buffer (get-buffer (car state))))
(if buffer
- (set-window-buffer window 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)))
+ (set-window-vscroll window (cdr (assq 'vscroll state)))
+ ;; Adjust vertically.
+ (if (memq window-size-fixed '(t height))
+ ;; A fixed height window, try to restore the
+ ;; original size.
+ (let ((delta (- (cdr (assq 'total-height item))
+ (window-total-height window)))
+ window-size-fixed)
+ (when (window-resizable-p window delta)
+ (window-resize window delta)))
+ ;; Else check whether the window is not high enough.
+ (let* ((min-size (window-min-size window nil ignore))
+ (delta (- min-size (window-total-size window))))
+ (when (and (> delta 0)
+ (window-resizable-p window delta nil ignore))
+ (window-resize window delta nil ignore))))
+ ;; Adjust horizontally.
+ (if (memq window-size-fixed '(t width))
+ ;; A fixed width window, try to restore the original
+ ;; size.
+ (let ((delta (- (cdr (assq 'total-width item))
+ (window-total-width window)))
+ window-size-fixed)
+ (when (window-resizable-p window delta)
+ (window-resize window delta)))
+ ;; Else check whether the window is not wide enough.
+ (let* ((min-size (window-min-size window t ignore))
+ (delta (- min-size (window-total-size window t))))
+ (when (and (> delta 0)
+ (window-resizable-p window delta t ignore))
+ (window-resize window delta t ignore))))
+ ;; 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-window-start window (cdr (assq 'start state)))
+ (set-window-point window (cdr (assq 'point state))))
+ ;; Select window if it's the selected one.
+ (when (cdr (assq 'selected state))
+ (select-window window)))
+ ;; 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)))
- (with-current-buffer (window-buffer window)
- (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)))
- (set-window-vscroll window (cdr (assq 'vscroll state)))
- ;; Adjust vertically.
- (if (memq window-size-fixed '(t height))
- ;; A fixed height window, try to restore the original size.
- (let ((delta (- (cdr (assq 'total-height item))
- (window-total-height window)))
- window-size-fixed)
- (when (window-resizable-p window delta)
- (window-resize window delta)))
- ;; Else check whether the window is not high enough.
- (let* ((min-size (window-min-size window nil ignore))
- (delta (- min-size (window-total-size window))))
- (when (and (> delta 0)
- (window-resizable-p window delta nil ignore))
- (window-resize window delta nil ignore))))
- ;; Adjust horizontally.
- (if (memq window-size-fixed '(t width))
- ;; A fixed width window, try to restore the original size.
- (let ((delta (- (cdr (assq 'total-width item))
- (window-total-width window)))
- window-size-fixed)
- (when (window-resizable-p window delta)
- (window-resize window delta)))
- ;; Else check whether the window is not wide enough.
- (let* ((min-size (window-min-size window t ignore))
- (delta (- min-size (window-total-size window t))))
- (when (and (> delta 0)
- (window-resizable-p window delta t ignore))
- (window-resize window delta t ignore))))
- ;; 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-window-start window (cdr (assq 'start state)))
- (set-window-point window (cdr (assq 'point state))))
- ;; Select window if it's the selected one.
- (when (cdr (assq 'selected state))
- (select-window window)))))))
+ (push window window-state-put-stale-windows)))))))
(defun window-state-put (state &optional window ignore)
"Put window state STATE into WINDOW.