Subject: bug#71386: 29.1; Frame is auto-deleted even when it has multiple tabs

From: Al Haji-Ali <[email-masked]>
Date: Tue, 18 Jun 2024 20:04:45 +0100

On 18/06/2024, martin rudalics wrote:
> We've been discussing changes to 'switch-to-prev-buffer' in Bug#69993
> but ended up in disagreement on what to do.  Juri then implemented a
> purely tab-bar based method.  For my Emacs I use an option that allows
> it to switch to buffers that have been already displayed at least once
> only and am quite happy with it (I've never managed to derive a suitable
> regexp for all buffers I never want to switch to).

I see. The change you suggested is definitely needed in any case and would address the main issue in this bug report (frame being deleted and losing tab configuration). I would just suggest that `window-deletable-functions` be renamed to `window-deletable-predicates` or `window-deletable-p-functions` (as Juri suggested in his very first patch) to emphasize that these should be side-effect-free predicates.

I guess the code that Juri originally suggested for tab-bar can also be used with `window-deletable-functions`.
,----
| (defun tab-bar-window-delete-frame-p (window kill)
|   "Prevent deletion of WINDOW and its frame when it contains tabs.
| Used in `'window-deletable-functions'."
|   (and tab-bar-mode (> (length (funcall tab-bar-tabs-function frame)) 1)))
|   
| (add-hook 'window-deletable-functions #'tab-bar-window-delete-frame-p)
`----

I'll check Bug#69993 and try to figure out how to close the tab when it has a single dedicated window from `switch-to-prev-buffer`, or maybe Juri has some ideas?

-- Al