Subject: bug#79159: [PATCH] Do not display in the tab line tabs that are excluded.

From: Juri Linkov <[email-masked]>
Date: Thu, 07 Aug 2025 09:20:00 +0300

>> 1. C-x b SPC *bar* RET
>> 2. C-x b foo RET
>> 3. C-x <left>
>>
>> It switches to the initial buffer *scratch*,
>> skipping the excluded buffer " *bar*".
>>
>> Without the proposed patch the tab-line is broken,
>> because it displays the excluded buffer,
>> but 'C-x <left>' can't switch to it.
>>
>> So tab-line.el should follow the logic of window.el
>> and omit excluded buffers as well.
>
> Yes, I've noticed this "bug", i have many buffers excluded, and when (for
> some reason) they appear in my tab line (or I accidentally switch to
> them), they are going to end up flooding my tab line, and it will be
> hard to switch buffers via "C-x <left>|<right>".

Do you mean that you customize not only 'tab-line-exclude-buffers',
but also 'switch-to-prev-buffer-skip' and 'switch-to-prev-buffer-skip-regexp'
to exclude the same buffers for both tab-line and "C-x <left>|<right>"?

>> Maybe the existing 'tab-line-tabs-buffer-list-function'
>> should be promoted to the user option.
>
> I like the idea, but the problem is that
> `tab-line-tabs-buffer-list-function' is used only for
> `tab-line-tabs-mode-buffers' and `tab-line-tabs-buffer-groups'.
>
> Maybe the function should take an optional argument if it should list
> only window buffers, so it can be used in
> 'tab-line-tabs-fixed-window-buffers' and others.

In fact it's needed only for 'tab-line-tabs-window-buffers'
and 'tab-line-tabs-fixed-window-buffers', but not for other,
because other such as 'tab-line-tabs-mode-buffers' and
'tab-line-tabs-buffer-groups' have own means to exclude buffers
from the tab-line using 'tab-line-tabs-buffer-list-function'.

So we could add a similar function e.g. 'tab-line-tabs-window-buffers-function'
for 'tab-line-tabs-window-buffers' and 'tab-line-tabs-fixed-window-buffers'
only.