all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Al Haji-Ali <abdo.haji.ali@gmail.com>, Juri Linkov <juri@linkov.net>
Cc: Eli Zaretskii <eliz@gnu.org>, 71386@debbugs.gnu.org
Subject: bug#71386: 29.1; Frame is auto-deleted even when it has multiple tabs
Date: Mon, 17 Jun 2024 16:47:07 +0200	[thread overview]
Message-ID: <87b7ee75-7c63-42ac-8551-c0d20a46ea43@gmx.at> (raw)
In-Reply-To: <m2frtdrwj1.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

 > Also if the proposed change to `window-deletable-p` is adopted, then a
 > grep on `window-deletable-p` also reveals that, for consistency,
 > `delete-windows-on` and even `calendar-exit` in `calendar.el` should
 > be modified similarly to `window--delete`.

This means that we should do the entire fix within 'window-deletable-p',
right?  That's not an internal function, so we can, in all conscience,
supply an abnormal hook as in the roughly tested patch attached.

martin

[-- Attachment #2: window-deletable-functions.diff --]
[-- Type: text/x-patch, Size: 2448 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index 604b9868921..04e38faa074 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4104,6 +4104,27 @@ one-window-p
 	(next-window base-window (if nomini 'arg) all-frames))))
 \f
 ;;; Deleting windows.
+(defcustom window-deletable-functions nil
+   "Abnormal hook to decide whether a window may be safely 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
+should be deleted together with its frame.  The window's buffer is
+current when running this hook.
+
+If any of these functions returns nil, the window will not be deleted
+and another buffer will be shown in it.  This hook is run by
+`window-deletable-p' which, in is turn, is called by `delete-windows-on'
+and `quit-restore-window'.  It is neither run by `delete-window' nor
+`delete-frame'.
+
+The purpose of this hook is to give its clients a chance to save a
+window or its frame from deletion because they might still want to use
+that window or frame for their own purposes."
+  :type 'hook
+  :version "30.1"
+  :group 'windows)
+
 (defun window-deletable-p (&optional window)
   "Return t if WINDOW can be safely deleted from its frame.
 WINDOW must be a valid window and defaults to the selected one.
@@ -4137,14 +4158,20 @@ window-deletable-p
 		    (and minibuf (eq frame (window-frame minibuf))
                          (not (eq (default-toplevel-value
                                     'minibuffer-follows-selected-frame)
-                                  t)))))
+                                  t))))
+		  (not (with-current-buffer (window-buffer window)
+			 (run-hook-with-args-until-failure
+			  'window-deletable-functions window t))))
 	'frame))
      ((window-minibuffer-p window)
       ;; If WINDOW is the minibuffer window of a non-minibuffer-only
       ;; frame, it cannot be deleted separately.
       nil)
-     ((or ignore-window-parameters
-	  (not (eq window (window-main-window frame))))
+     ((and (or ignore-window-parameters
+	       (not (eq window (window-main-window frame))))
+	   (with-current-buffer (window-buffer window)
+	     (run-hook-with-args-until-failure
+	      'window-deletable-functions window nil)))
       ;; Otherwise, WINDOW can be deleted unless it is the main window
       ;; of its frame.
       t))))

  reply	other threads:[~2024-06-17 14:47 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 23:44 bug#71386: 29.1; Frame is auto-deleted even when it has multiple tabs Al Haji-Ali
2024-06-06  5:45 ` Eli Zaretskii
2024-06-06  6:12   ` Juri Linkov
2024-06-06  9:20     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-06 10:10     ` Eli Zaretskii
2024-06-06  9:19   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-07  6:39     ` Juri Linkov
2024-06-07  8:23       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-07 17:20         ` Juri Linkov
2024-06-07 17:52           ` Eli Zaretskii
2024-06-07 18:16             ` Juri Linkov
2024-06-07 18:44               ` Al Haji-Ali
2024-06-09 16:59                 ` Juri Linkov
2024-06-09 17:46                   ` Eli Zaretskii
2024-06-09 17:58                     ` Juri Linkov
2024-06-09 18:16                       ` Eli Zaretskii
2024-06-09 18:28                         ` Juri Linkov
2024-06-10  8:00                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-11  6:58                             ` Juri Linkov
2024-06-11 16:26                               ` Al Haji-Ali
2024-06-13  6:50                                 ` Juri Linkov
2024-06-12  8:57                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-13  6:53                                 ` Juri Linkov
2024-06-13  8:21                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-14  6:13                                     ` Juri Linkov
2024-06-14 17:46                                     ` Juri Linkov
2024-06-15  8:42                                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-16  6:58                                         ` Juri Linkov
2024-06-16  7:52                                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-16 10:50                                             ` Al Haji-Ali
2024-06-17 14:47                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-17 16:08                                                 ` Al Haji-Ali
2024-06-17 16:47                                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-17 17:01                                                     ` Al Haji-Ali
2024-06-18  9:52                                                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-18 19:04                                                         ` Al Haji-Ali
2024-06-19  6:24                                                           ` Juri Linkov
2024-06-19  9:37                                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-20  6:48                                                               ` Juri Linkov
2024-06-20  9:29                                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-16 16:45                                             ` Juri Linkov
2024-06-17  6:16                                               ` Juri Linkov
2024-06-17 14:47                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-07 19:50               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87b7ee75-7c63-42ac-8551-c0d20a46ea43@gmx.at \
    --to=bug-gnu-emacs@gnu.org \
    --cc=71386@debbugs.gnu.org \
    --cc=abdo.haji.ali@gmail.com \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.