GNU bug report logs -
#71386
29.1; Frame is auto-deleted even when it has multiple tabs
Previous Next
Reported by: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Date: Thu, 6 Jun 2024 00:11:02 UTC
Severity: wishlist
Found in version 29.1
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
>> Sorry, I don't understand what I should do in tab-bar-mode
>> for quit-restore-window. I expected that changes should be
>> in window.el.
>
> Provide an option, say 'tab-bar-save-frame', that allows users to
> customize whether a frame should be deleted when "other tabs are
> available for that frame". And provide a function, say
> 'tab-bar-save-frame-p', 'window--delete' could call thusly
Ok, here is a better patch:
[window-delete-frame-predicate-functions.patch (text/x-diff, inline)]
diff --git a/lisp/window.el b/lisp/window.el
index 2208346ec8c..abc9f1b4011 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4968,6 +4968,10 @@ frame-auto-hide-function
:group 'frames
:version "26.1")
+(defvar window-delete-frame-predicate-functions nil
+ "Don't delete frame when one of functions returns t.
+Called with two arguments: FRAME and KILL.")
+
(defun window--delete (&optional window dedicated-only kill)
"Delete WINDOW if possible.
WINDOW must be a live window and defaults to the selected one.
@@ -4982,6 +4986,10 @@ window--delete
((eq deletable 'frame)
(let ((frame (window-frame window)))
(cond
+ ((run-hook-with-args-until-success
+ 'window-delete-frame-predicate-functions
+ frame kill)
+ nil)
(kill
(delete-frame frame))
((functionp (frame-parameter frame 'auto-hide-function))
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index dac57ce2070..25bfefbc205 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -2631,6 +2631,14 @@ tab-switcher-mouse-select
(goto-char (posn-point (event-end event)))
(tab-switcher-select))
+
+(defun tab-bar-window-delete-frame-p (frame _kill)
+ "Whether FRAME should be deleted when other tabs are available for that frame.
+Used via `window-delete-frame-predicate-functions' by `window--delete'."
+ (and tab-bar-mode (> (length (funcall tab-bar-tabs-function frame)) 1)))
+
+(add-hook 'window-delete-frame-predicate-functions #'tab-bar-window-delete-frame-p)
+
(defun tab-bar--reusable-frames (all-frames)
(cond
This bug report was last modified 34 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.