aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics <[email protected]>2013-07-06 16:24:54 +0200
committerJuanma Barranquero <[email protected]>2013-07-06 16:24:54 +0200
commit34ada5f476dbd018cf523b127586f44ebb191e3a (patch)
tree3ebb64c5c78fa2ec190d629768a7cedaa0484cf7
parent11e03d8900001e858fdecbe557469245de03e7fa (diff)
lisp/window.el (window-state-put): Remove window if buffer was not restored.
(window-state-put-stale-windows): New variable. (window--state-put-2): Save list of windows without matching buffer. (window-state-put): Remove "bufferless" windows if possible.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/window.el19
2 files changed, 22 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 49fc7449a3..0b7c65b218 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2013-07-06 Martin Rudalics <[email protected]>
+
+ * window.el (window-state-put-stale-windows): New variable.
+ (window--state-put-2): Save list of windows without matching buffer.
+ (window-state-put): Remove "bufferless" windows if possible.
+
2013-07-06 Juanma Barranquero <[email protected]>
* simple.el (alternatives-define): Remove leftover :group keyword.
diff --git a/lisp/window.el b/lisp/window.el
index fc50bbb0d4..a2acd2a81b 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4347,6 +4347,9 @@ value can be also stored on disk and read back in a new session."
(defvar window-state-put-list nil
"Helper variable for `window-state-put'.")
+(defvar window-state-put-stale-windows nil
+ "Helper variable for `window-state-put'.")
+
(defun window--state-put-1 (state &optional window ignore totals)
"Helper function for `window-state-put'."
(let ((type (car state)))
@@ -4429,9 +4432,14 @@ 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 here so we create a buffer if
- ;; there's none.
- (set-window-buffer window (get-buffer-create (car 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)
+ (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
@@ -4491,6 +4499,7 @@ Optional argument IGNORE non-nil means ignore minimum window
sizes and fixed size restrictions. IGNORE equal `safe' means
windows can get as small as `window-safe-min-height' and
`window-safe-min-width'."
+ (setq window-state-put-stale-windows nil)
(setq window (window-normalize-window window t))
(let* ((frame (window-frame window))
(head (car state))
@@ -4539,6 +4548,10 @@ windows can get as small as `window-safe-min-height' and
(set-window-buffer window (current-buffer))
(window--state-put-1 state window nil totals)
(window--state-put-2 ignore))
+ (while window-state-put-stale-windows
+ (let ((window (pop window-state-put-stale-windows)))
+ (when (eq (window-deletable-p window) t)
+ (delete-window window))))
(window--check frame))))
(defun display-buffer-record-window (type window buffer)