From c089653d568d5c696f2d35e1bcf9bba64af85b97 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Sun, 15 Sep 2013 18:08:04 +0200 Subject: [PATCH] In window--state-put-2 don't process buffer state when buffer doesn't exist (Bug#15382). * window.el (window--state-put-2): Don't process buffer state when buffer doesn't exist any more (Bug#15382). --- lisp/ChangeLog | 5 +++ lisp/window.el | 110 +++++++++++++++++++++++++------------------------ 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e151ca9312b..01400a96009 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-09-15 Martin Rudalics + + * window.el (window--state-put-2): Don't process buffer state + when buffer doesn't exist any more (Bug#15382). + 2013-09-15 Glenn Morris * eshell/em-unix.el (eshell/rm): diff --git a/lisp/window.el b/lisp/window.el index a111b3cb5b4..14e9f6bc128 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4464,62 +4464,66 @@ value can be also stored on disk and read back in a new session." (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. -- 2.39.2