From 8e009b788144d2a3a4a628e32d812718dee98109 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Wed, 19 Feb 2014 10:54:35 +0100 Subject: [PATCH] In window-state-put allow WINDOW to refer to an internal window (Bug#16793). * window.el (window-state-put): Allow WINDOW to refer to an internal window (Bug#16793). --- lisp/ChangeLog | 5 +++++ lisp/window.el | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4827fedace1..27c681bd945 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-02-19 Martin Rudalics + + * window.el (window-state-put): Allow WINDOW to refer to an + internal window (Bug#16793). + 2014-02-19 Glenn Morris * textmodes/remember.el: Move provide statement to end. diff --git a/lisp/window.el b/lisp/window.el index fab96cbabd5..c4854f02399 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5026,14 +5026,32 @@ value can be also stored on disk and read back in a new session." "Put window state STATE into WINDOW. STATE should be the state of a window returned by an earlier invocation of `window-state-get'. Optional argument WINDOW must -specify a live window and defaults to the selected one. +specify a valid window and defaults to the selected one. If +WINDOW is not live, replace WINDOW by a live one before putting +STATE into it. 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)) + (setq window (window-normalize-window window)) + + ;; When WINDOW is internal, reduce it to a live one to put STATE into, + ;; see Bug#16793. + (unless (window-live-p window) + (let ((root (frame-root-window window))) + (if (eq window root) + (setq window (frame-first-window root)) + (setq root window) + (setq window (catch 'live + (walk-window-subtree + (lambda (window) + (when (window-live-p window) + (throw 'live window))) + root)))) + (delete-other-windows-internal window root))) + (let* ((frame (window-frame window)) (head (car state)) ;; We check here (1) whether the total sizes of root window of -- 2.39.2