bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62575: 29.0.60; Tabs are not showing the right names of the buffers


From: Juri Linkov
Subject: bug#62575: 29.0.60; Tabs are not showing the right names of the buffers
Date: Sun, 02 Apr 2023 09:48:58 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

>> The bug: the third Tab still keeps its  .emacs  label, the click on the 
>> second Tab labeled  .emacs  did not show the .emacs file, but the buffer 
>> *Messages*.
>
> After looking at the code, I'm not sure this is a bug.  The tab names
> are just labels, although they are conveniently set to the name of the
> buffer in the window to be selected when the tab is current.  But
> otherwise they are just labels.  When you click on the tab, its name
> is updated to reflect the buffer shown in the selected window, so I
> think Emacs is behaving correctly, although it might be a bit
> unexpected.
>
> Juri, am I right?  If not, where is the code that's supposed to update
> the labels when some buffers or windows are deleted or renamed?

Right, tab names are just labels, or by another analogy are "bookmarks".
It was a design decision to keep labels even after a buffer is killed,
so the users know what buffer was displayed in the tab created to
display that buffer.

What we could do is to help to create additional code that could be
used to update tab names according to user wishes.

But the problem is that there are too many ways to do this,
so the implementation logic is too fuzzy and not well defined.
Here are some considerations that could be took into account:

1. First there is no need to update tabs with names set explicitly
   by 'tab-rename' (C-x t r).

2. Also no need to update a tab name when non-current buffers
   are killed on a window configuration saved to the tab,
   in case when tab-bar-tab-name-function is unchanged from
   its default value tab-bar-tab-name-current.  However,
   when it's customized to tab-bar-tab-name-all, then
   killing any buffer on the window configuration can change
   the tab name.  There are other values that may or may not
   change the tab name after the buffer is killed.

3. It seems the reported wish was to rename the tab
   after the buffer was killed.  But I imagine some users
   instead might prefer to automatically close all tabs that
   displayed the killed buffer.  This also makes sense.

4. As noted by Ruijie, the code should react not only
   to killing a buffer, but also to renaming a buffer.
   This means that instead of using kill-buffer-hook,
   it should rely on buffer-list-update-hook, but
   the problem is that buffer-list-update-hook is
   not called with a buffer name, so need to develop
   much more complicated code.

I invite Claudio and anyone to try the code I wrote
for bug#52019 and bug#60096 as a staring point.
Then after fulfilling the expectations, it could be
later added to tab-bar.el as an option:

;; Visit affected tabs to update their names:
(add-hook 'kill-buffer-hook
          (lambda ()
            (let ((tabs (reverse
                         (mapcar (lambda (tab) (1+ (alist-get 'index tab)))
                                 (tab-bar-get-buffer-tab nil t nil t)))))
              (run-with-timer
               0 nil
               (lambda (tabs) (dolist (tab tabs) (tab-bar-select-tab tab)))
               tabs))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]