]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/window.el (window-deletable-p): Improve tab handling.
authorJuri Linkov <juri@linkov.net>
Thu, 3 Apr 2025 16:28:41 +0000 (19:28 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Apr 2025 16:52:14 +0000 (18:52 +0200)
Use frame parameter 'tab-bar-lines' instead of 'tab-bar-mode'.
Remove 'window-dedicated-p' (bug#71386).  Doc fix.
Add 'frame' arg to 'window-list-1' (bug#59862).

(cherry picked from commit 79fd696d141f22676d72caf3ae21c9f79e59b91a)

lisp/window.el

index 50f7c90a080eac3435e59a73a8e8e1d494d218b9..0e89b490aece6851cb8ecba0d9afc3575ae3c2de 100644 (file)
@@ -4090,7 +4090,7 @@ and no others."
 \f
 ;;; Deleting windows.
 (defcustom window-deletable-functions nil
-   "Abnormal hook to decide whether a window may be implicitly deleted.
+  "Abnormal hook to decide whether a window may be implicitly deleted.
 The value should be a list of functions that take two arguments.  The
 first argument is the window about to be deleted.  The second argument
 if non-nil, means that the window is the only window on its frame and
@@ -4115,6 +4115,9 @@ WINDOW must be a valid window and defaults to the selected one.
 Return `frame' if WINDOW is the root window of its frame and that
 frame can be safely deleted.
 
+Return `tab' if WINDOW's tab can be safely closed that will
+effectively delete the window.
+
 Unless the optional argument NO-RUN is non-nil, run the abnormal hook
 `window-deletable-functions' and return nil if any function on that hook
 returns nil."
@@ -4128,19 +4131,18 @@ returns nil."
 
   (let ((frame (window-frame window)))
     (cond
-     ((and tab-bar-mode
-           ;; Fall back to frame handling in case of less than 2 tabs
+     ((and (> (frame-parameter frame 'tab-bar-lines) 0)
+           ;; Fall back to frame handling in case of less than 2 tabs.
            (> (length (funcall tab-bar-tabs-function frame)) 1)
-           ;; Close the tab with the initial window (bug#59862)
+           ;; Close the tab with the initial window (bug#59862).
            (or (eq (nth 1 (window-parameter window 'quit-restore)) 'tab)
-               ;; or with the dedicated window (bug#71386)
-               (and (window-dedicated-p window)
-                    (frame-root-window-p window)))
-           ;; Don't close the tab if more windows were created explicitly
+               ;; Or with the only window on the frame (bug#71386).
+               (frame-root-window-p window))
+           ;; Don't close the tab if more windows were created explicitly.
            (< (seq-count (lambda (w)
                            (memq (car (window-parameter w 'quit-restore))
                                  '(window tab frame same)))
-                         (window-list-1 nil 'nomini))
+                         (window-list-1 nil 'nomini frame))
               2))
       'tab)
      ((frame-root-window-p window)