bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#59862: quit-restore per window buffer


From: Juri Linkov
Subject: bug#59862: quit-restore per window buffer
Date: Sun, 14 Jul 2024 10:49:35 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>> Ok, I will try to move it.
>
> We could replace the
>
>          (or (eq (nth 1 quit-restore) 'frame)
>              (and (eq (nth 1 quit-restore) 'window)
>                   ;; If the window has been created on an existing
>                   ;; frame and ended up as the sole window on that
>                   ;; frame, do not delete it (Bug#12764).
>                   (not (eq window (frame-root-window window)))))
>
> clause with
>
>          (or (eq (nth 1 quit-restore) 'frame)
>              ;; If the window has been created on an existing
>              ;; frame and ended up as the sole window on that
>              ;; frame, do not delete it (Bug#12764).
>              (not (eq window (frame-root-window window))))
>
> with the motivation that if a window does not have a previous buffer,
> there is no reason to switch to it.  This will keep the frame around so
> Bu#12764 is not affected and the normal behavior of C-h i followed by
> C-h e is not affected either unless a user deleted *scratch* in between.

Sorry, I know nothing about the frame case.

> Try it and if it works for you I'll add it to the new patch.

OTOH, I tried to add the tab case handling to the same places
where the frame case is handled, and everything works nicely
with this patch applied over your previous patches:

diff --git a/lisp/window.el b/lisp/window.el
index 58120c919c7..82efb3c40ce 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4120,6 +4120,11 @@ window-deletable-p
 
   (let ((frame (window-frame window)))
     (cond
+     ((and (eq (nth 1 (window-parameter window 'quit-restore)) 'tab)
+          (< (seq-count (lambda (w) (window-parameter w 'quit-restore))
+                        (window-list-1 nil 'nomini))
+             2))
+      'tab)
      ((frame-root-window-p window)
       ;; WINDOW's frame can be deleted only if there are other frames
       ;; on the same terminal, and it does not contain the active
@@ -4990,6 +4995,9 @@ window--delete
   (unless (and dedicated-only (not (window-dedicated-p window)))
     (let ((deletable (window-deletable-p window)))
       (cond
+       ((eq deletable 'tab)
+       (tab-bar-close-tab)
+       'tab)
        ((eq deletable 'frame)
        (let ((frame (window-frame window)))
          (cond
@@ -5303,10 +5311,8 @@ quit-restore-window
      ((and (not prev-buffer)
           (eq (nth 1 quit-restore) 'tab)
           (eq (nth 3 quit-restore) buffer)
-          (< (seq-count (lambda (w) (window-parameter w 'quit-restore))
-                        (window-list-1 nil 'nomini))
-              2))
-      (tab-bar-close-tab)
+          (window--delete
+           window nil (memq bury-or-kill '(kill killing))))
       ;; If the previously selected window is still alive, select it.
       (window--quit-restore-select-window quit-restore-2))
      ((and (not prev-buffer)





reply via email to

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