aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov2018-11-08 00:20:16 +0200
committerJuri Linkov2018-11-08 00:20:16 +0200
commit4254caa2d3bc2ebec6513fccce6a3d6303b068ef (patch)
tree26f1eddb42b7eac27530d547fb9162ea4e368226 /lisp
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/window.el35
1 files changed, 20 insertions, 15 deletions
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