From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#71386: 29.1; Frame is auto-deleted even when it has multiple tabs Date: Fri, 07 Jun 2024 20:20:03 +0300 Organization: LINKOV.NET Message-ID: <86msnw4qm4.fsf@mail.linkov.net> References: <86ikymipzx.fsf@gnu.org> <7269c7c4-86a1-44bf-8d5d-378c3584027a@gmx.at> <86zfrx8ec0.fsf@mail.linkov.net> <8561a63a-66d3-44cd-872f-73d26af7edbe@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9514"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , Al Haji-Ali , 71386@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 08 01:52:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sFjNR-0002KC-I4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Jun 2024 01:52:09 +0200 Original-Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFdIf-00025V-Oo; Fri, 07 Jun 2024 13:22:51 -0400 Original-Received: from [2001:470:142:3::10] (helo=eggs.gnu.org) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFdId-00025N-Nu for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 13:22:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFdId-0007Fg-GO for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 13:22:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sFdIs-0003Ih-Et for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 13:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jun 2024 17:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71386 X-GNU-PR-Package: emacs Original-Received: via spool by 71386-submit@debbugs.gnu.org id=B71386.171778095912617 (code B ref 71386); Fri, 07 Jun 2024 17:23:02 +0000 Original-Received: (at 71386) by debbugs.gnu.org; 7 Jun 2024 17:22:39 +0000 Original-Received: from localhost ([127.0.0.1]:44676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFdIV-0003HR-AB for submit@debbugs.gnu.org; Fri, 07 Jun 2024 13:22:39 -0400 Original-Received: from mslow1.mail.gandi.net ([217.70.178.240]:47443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFdIT-0003H6-Md for 71386@debbugs.gnu.org; Fri, 07 Jun 2024 13:22:38 -0400 Original-Received: from relay5-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::225]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 802BBC6C10 for <71386@debbugs.gnu.org>; Fri, 7 Jun 2024 17:21:48 +0000 (UTC) Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 338A01C0003; Fri, 7 Jun 2024 17:21:26 +0000 (UTC) In-Reply-To: <8561a63a-66d3-44cd-872f-73d26af7edbe@gmx.at> (martin rudalics's message of "Fri, 7 Jun 2024 10:23:52 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286793 Archived-At: --=-=-= Content-Type: text/plain >> 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=window-delete-frame-predicate-functions.patch 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 --=-=-=--