emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4254caa: * lisp/window.el (window-state-put): Creat


From: Juri Linkov
Subject: [Emacs-diffs] master 4254caa: * lisp/window.el (window-state-put): Create a new window
Date: Wed, 7 Nov 2018 17:20:23 -0500 (EST)

branch: master
commit 4254caa2d3bc2ebec6513fccce6a3d6303b068ef
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * lisp/window.el (window-state-put): Create a new window
    
    to replace the existing one on the same frame in case
    when WINDOW is not live.  (Bug#32850)
    
    * doc/lispref/windows.texi (Window Configurations):
    Describe changes related to WINDOW arg of window-state-put.
---
 doc/lispref/windows.texi |  7 ++++---
 lisp/window.el           | 35 ++++++++++++++++++++---------------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 772bcdf..9301fdf 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -5706,9 +5706,10 @@ This function puts the window state @var{state} into 
@var{window}.
 The argument @var{state} should be the state of a window returned by
 an earlier invocation of @code{window-state-get}, see above.  The
 optional argument @var{window} can be either a live window or an
-internal window (@pxref{Windows and Frames}) and defaults to the
-selected one.  If @var{window} is not live, it is replaced by a live
-window before putting @var{state} into it.
+internal window (@pxref{Windows and Frames}).  If @var{window} is not
+a live window, it is replaced by a new live window created on the same
+frame before putting @var{state} into it.  If @var{window} is @code{nil},
+it puts the window state into a new window.
 
 If the optional argument @var{ignore} is address@hidden, it means to ignore
 minimum window sizes and fixed-size restrictions.  If @var{ignore}
diff --git a/lisp/window.el b/lisp/window.el
index bcd4fa2..c0eeba7 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2764,7 +2764,7 @@ as small) as possible, but don't signal an error."
   "Return t when a window on FRAME shall be resized vertically.
 Optional argument HORIZONTAL non-nil means return t when a window
 shall be resized horizontally."
-(catch 'apply
+  (catch 'apply
     (walk-window-tree
      (lambda (window)
        (unless (= (window-new-pixel window)
@@ -5889,29 +5889,34 @@ 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 valid window and defaults to the selected one.  If
-WINDOW is not live, replace WINDOW by a live one before putting
-STATE into it.
+specify a valid window.  If WINDOW is not a live window,
+replace WINDOW by a new live window created on the same frame.
+If WINDOW is nil, create a new window 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))
 
-  ;; When WINDOW is internal, reduce it to a live one to put STATE into,
-  ;; see Bug#16793.
+  ;; When WINDOW is internal or nil, reduce it to a live one,
+  ;; then create a new window on the same frame to put STATE into.
   (unless (window-live-p window)
     (let ((root window))
-      (setq window (catch 'live
-                     (walk-window-subtree
-                      (lambda (window)
-                        (when (and (window-live-p window)
-                                   (not (window-parameter window 
'window-side)))
-                          (throw 'live window)))
-                      root)))
-      (delete-other-windows-internal window root)))
+      (setq window (if root
+                       (catch 'live
+                         (walk-window-subtree
+                          (lambda (window)
+                            (when (and (window-live-p window)
+                                       (not (window-parameter
+                                             window 'window-side)))
+                              (throw 'live window)))
+                          root))
+                     (selected-window)))
+      (delete-other-windows-internal window root)
+      ;; Create a new window to replace the existing one.
+      (setq window (prog1 (split-window window)
+                     (delete-window window)))))
 
   (set-window-dedicated-p window nil)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]