aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorMartin Rudalics2021-06-10 09:14:21 +0200
committerMartin Rudalics2021-06-10 09:14:21 +0200
commitb3dd0ce75ba9314eb7a682e5fcf8b4cfbc67655b (patch)
treeab7873f3a18ce3873200863e37fed9534558ce93 /src/window.c
parentdd9385b404c28a155a91960a4f1c4c77fdc5413d (diff)
downloademacs-b3dd0ce75ba9314eb7a682e5fcf8b4cfbc67655b.tar.gz
emacs-b3dd0ce75ba9314eb7a682e5fcf8b4cfbc67655b.zip
Provide new option `delete-window-set-selected' (Bug#47300)
When `delete-window' deletes its frame's selected window, this new option allows to choose another window as replacement. * lisp/window.el (get-lru-window, get-mru-window) (get-largest-window): New optional argument NO-OTHER. (window-at-pos): New function. (delete-window-set-selected): New option. (delete-window): Handle `delete-window-set-selected'. * src/window.c (Fdelete_window_internal): Set the selected window of WINDOW's frame to the first window on that frame and let `delete-window' choose a more suitable window instead. * doc/lispref/windows.texi (Deleting Windows): Describe new option `delete-window-set-selected'. (Cyclic Window Ordering): Describe new NO-OTHER argument for `get-lru-window', `get-mru-window' and `get-largest-window'. * etc/NEWS: Mention `delete-window-set-selected' and the NO-OTHER argument.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/window.c b/src/window.c
index 2d98ae5f156..db324effcce 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5148,15 +5148,13 @@ Signal an error when WINDOW is the only window on its frame. */)
5148 adjust_frame_glyphs (f); 5148 adjust_frame_glyphs (f);
5149 5149
5150 if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f))) 5150 if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f)))
5151 /* We deleted the frame's selected window. */ 5151 /* We apparently deleted the frame's selected window; use the
5152 frame's first window as substitute but don't record it yet.
5153 `delete-window' may have something better up its sleeves. */
5152 { 5154 {
5153 /* Use the frame's first window as fallback ... */ 5155 /* Use the frame's first window as fallback ... */
5154 Lisp_Object new_selected_window = Fframe_first_window (frame); 5156 Lisp_Object new_selected_window = Fframe_first_window (frame);
5155 /* ... but preferably use its most recently used window. */
5156 Lisp_Object mru_window;
5157 5157
5158 /* `get-mru-window' might fail for some reason so play it safe
5159 - promote the first window _without recording it_ first. */
5160 if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) 5158 if (EQ (FRAME_SELECTED_WINDOW (f), selected_window))
5161 Fselect_window (new_selected_window, Qt); 5159 Fselect_window (new_selected_window, Qt);
5162 else 5160 else
@@ -5164,24 +5162,9 @@ Signal an error when WINDOW is the only window on its frame. */)
5164 last selected window on F was an active minibuffer, we 5162 last selected window on F was an active minibuffer, we
5165 want to return to it on a later Fselect_frame. */ 5163 want to return to it on a later Fselect_frame. */
5166 fset_selected_window (f, new_selected_window); 5164 fset_selected_window (f, new_selected_window);
5167
5168 unblock_input ();
5169
5170 /* Now look whether `get-mru-window' gets us something. */
5171 mru_window = call1 (Qget_mru_window, frame);
5172 if (WINDOW_LIVE_P (mru_window)
5173 && EQ (XWINDOW (mru_window)->frame, frame))
5174 new_selected_window = mru_window;
5175
5176 /* If all ended up well, we now promote the mru window. */
5177 if (EQ (FRAME_SELECTED_WINDOW (f), selected_window))
5178 Fselect_window (new_selected_window, Qnil);
5179 else
5180 fset_selected_window (f, new_selected_window);
5181 } 5165 }
5182 else
5183 unblock_input ();
5184 5166
5167 unblock_input ();
5185 FRAME_WINDOW_CHANGE (f) = true; 5168 FRAME_WINDOW_CHANGE (f) = true;
5186 } 5169 }
5187 else 5170 else