aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2018-11-08 00:20:16 +0200
committerJuri Linkov2018-11-08 00:20:16 +0200
commit4254caa2d3bc2ebec6513fccce6a3d6303b068ef (patch)
tree26f1eddb42b7eac27530d547fb9162ea4e368226
parent811d9291fcfb12d87bad277d4e8b25152129d73d (diff)
downloademacs-4254caa2d3bc2ebec6513fccce6a3d6303b068ef.tar.gz
emacs-4254caa2d3bc2ebec6513fccce6a3d6303b068ef.zip
* 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.
-rw-r--r--doc/lispref/windows.texi7
-rw-r--r--lisp/window.el35
2 files changed, 24 insertions, 18 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 772bcdf9a6c..9301fdfa9d6 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}.
5706The argument @var{state} should be the state of a window returned by 5706The argument @var{state} should be the state of a window returned by
5707an earlier invocation of @code{window-state-get}, see above. The 5707an earlier invocation of @code{window-state-get}, see above. The
5708optional argument @var{window} can be either a live window or an 5708optional argument @var{window} can be either a live window or an
5709internal window (@pxref{Windows and Frames}) and defaults to the 5709internal window (@pxref{Windows and Frames}). If @var{window} is not
5710selected one. If @var{window} is not live, it is replaced by a live 5710a live window, it is replaced by a new live window created on the same
5711window before putting @var{state} into it. 5711frame before putting @var{state} into it. If @var{window} is @code{nil},
5712it puts the window state into a new window.
5712 5713
5713If the optional argument @var{ignore} is non-@code{nil}, it means to ignore 5714If the optional argument @var{ignore} is non-@code{nil}, it means to ignore
5714minimum window sizes and fixed-size restrictions. If @var{ignore} 5715minimum window sizes and fixed-size restrictions. If @var{ignore}
diff --git a/lisp/window.el b/lisp/window.el
index bcd4fa29590..c0eeba7261d 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2764,7 +2764,7 @@ as small) as possible, but don't signal an error."
2764 "Return t when a window on FRAME shall be resized vertically. 2764 "Return t when a window on FRAME shall be resized vertically.
2765Optional argument HORIZONTAL non-nil means return t when a window 2765Optional argument HORIZONTAL non-nil means return t when a window
2766shall be resized horizontally." 2766shall be resized horizontally."
2767(catch 'apply 2767 (catch 'apply
2768 (walk-window-tree 2768 (walk-window-tree
2769 (lambda (window) 2769 (lambda (window)
2770 (unless (= (window-new-pixel window) 2770 (unless (= (window-new-pixel window)
@@ -5889,29 +5889,34 @@ value can be also stored on disk and read back in a new session."
5889 "Put window state STATE into WINDOW. 5889 "Put window state STATE into WINDOW.
5890STATE should be the state of a window returned by an earlier 5890STATE should be the state of a window returned by an earlier
5891invocation of `window-state-get'. Optional argument WINDOW must 5891invocation of `window-state-get'. Optional argument WINDOW must
5892specify a valid window and defaults to the selected one. If 5892specify a valid window. If WINDOW is not a live window,
5893WINDOW is not live, replace WINDOW by a live one before putting 5893replace WINDOW by a new live window created on the same frame.
5894STATE into it. 5894If WINDOW is nil, create a new window before putting STATE into it.
5895 5895
5896Optional argument IGNORE non-nil means ignore minimum window 5896Optional argument IGNORE non-nil means ignore minimum window
5897sizes and fixed size restrictions. IGNORE equal `safe' means 5897sizes and fixed size restrictions. IGNORE equal `safe' means
5898windows can get as small as `window-safe-min-height' and 5898windows can get as small as `window-safe-min-height' and
5899`window-safe-min-width'." 5899`window-safe-min-width'."
5900 (setq window-state-put-stale-windows nil) 5900 (setq window-state-put-stale-windows nil)
5901 (setq window (window-normalize-window window))
5902 5901
5903 ;; When WINDOW is internal, reduce it to a live one to put STATE into, 5902 ;; When WINDOW is internal or nil, reduce it to a live one,
5904 ;; see Bug#16793. 5903 ;; then create a new window on the same frame to put STATE into.
5905 (unless (window-live-p window) 5904 (unless (window-live-p window)
5906 (let ((root window)) 5905 (let ((root window))
5907 (setq window (catch 'live 5906 (setq window (if root
5908 (walk-window-subtree 5907 (catch 'live
5909 (lambda (window) 5908 (walk-window-subtree
5910 (when (and (window-live-p window) 5909 (lambda (window)
5911 (not (window-parameter window 'window-side))) 5910 (when (and (window-live-p window)
5912 (throw 'live window))) 5911 (not (window-parameter
5913 root))) 5912 window 'window-side)))
5914 (delete-other-windows-internal window root))) 5913 (throw 'live window)))
5914 root))
5915 (selected-window)))
5916 (delete-other-windows-internal window root)
5917 ;; Create a new window to replace the existing one.
5918 (setq window (prog1 (split-window window)
5919 (delete-window window)))))
5915 5920
5916 (set-window-dedicated-p window nil) 5921 (set-window-dedicated-p window nil)
5917 5922