GNU bug report logs - #79159
[PATCH] Do not display in the tab line tabs that are excluded.

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sat, 2 Aug 2025 20:02:02 UTC

Severity: normal

Tags: patch

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

To reply to this bug, email your comments to 79159 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Sat, 02 Aug 2025 20:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 02 Aug 2025 20:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Do not display in the tab line tabs that are excluded.
Date: Sat, 02 Aug 2025 14:00:27 -0600
[Message part 1 (text/plain, inline)]
Tags: patch

tab-line by default displays all the tabs in the tab line, however this
also includes the tab that are excluded in 'tab-line-exclude-modes' and
'tab-line-exclude-buffers', which IMO makes no sense.

The patch attached, solves this.

Currently, it only works for 'tab-line-tabs-fixed-window-buffers'.

[0001-Do-not-display-in-the-tab-line-tabs-that-are-exclude.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
- E.G via Gnus and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Sun, 03 Aug 2025 05:14:01 GMT) Full text and rfc822 format available.

Message #8 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Sun, 03 Aug 2025 08:13:41 +0300
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Date: Sat, 02 Aug 2025 14:00:27 -0600
> 
> tab-line by default displays all the tabs in the tab line, however this
> also includes the tab that are excluded in 'tab-line-exclude-modes' and
> 'tab-line-exclude-buffers', which IMO makes no sense.

I think "makes no sense" is in the eyes of the beholder.  These
variables determine which buffers should have the tab-line shown in
their windows, they don't mean these buffers should not be reachable
via the tab-line in other buffers.  Hiding them in all tab-lines means
you cannot switch to those buffers except via "C-x b" or somesuch.
That is not the intent of these variables, AFAIU.  Their intent is to
disable tab-line in buffers where showing the tab-line makes no sense.
The default value of tab-line-exclude-modes is a good example of that.

But I won't object to adding a knob to have the behavior you want, if
Juri agrees, and there are no other objections.  However, this must be
an opt-in behavior, by default off.

> Currently, it only works for 'tab-line-tabs-fixed-window-buffers'.

Which IMO is a limitation that should be lifted, for this feature to
make sense.  I expect to see bug reports if we don't.

> +*** 'tab-line-tabs-fixed-window-buffers' now hides the excluded tabs.
> +All the buffers included in 'tab-line-exclude-buffers' and
> +'tab-line-exclude-modes' will not appear in the tab line only if
> +'tab-line-tabs-function' is set to 'tab-line-tabs-fixed-window-buffers'.

A buffer cannot be "included" in a list of modes, so talking about a
buffer included in tab-line-exclude-modes is confusing.  I suggest to
reword:

  *** Excluded buffers are no longer shown in tab-lines of other buffers.
  Buffers that match 'tab-line-exclude-buffers' and buffers whose
  modes are in 'tab-line-exclude-modes' will not appear in tab-lines
  of other buffers.

Also, why isn't there either "+++" (and a suitable change to the
manual) or "---" for this entry?  We don't want to defer the decision
whether and how to document the changes in the manuals to the time
when a release will be prepared, we want to make the necessary
documentation changes right away.  So let's please decide now whether
this change deserves to be mentioned in the manuals, and act
accordingly.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Mon, 04 Aug 2025 02:40:02 GMT) Full text and rfc822 format available.

Message #11 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79159 <at> debbugs.gnu.org
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Sun, 03 Aug 2025 20:38:48 -0600
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
>> Date: Sat, 02 Aug 2025 14:00:27 -0600
>> 
>> tab-line by default displays all the tabs in the tab line, however
>> this
>> also includes the tab that are excluded in 'tab-line-exclude-modes'
>> and
>> 'tab-line-exclude-buffers', which IMO makes no sense.
>
> I think "makes no sense" is in the eyes of the beholder.  These
> variables determine which buffers should have the tab-line shown in
> their windows, they don't mean these buffers should not be reachable
> via the tab-line in other buffers.  Hiding them in all tab-lines means
> you cannot switch to those buffers except via "C-x b" or somesuch.
> That is not the intent of these variables, AFAIU.  Their intent is to
> disable tab-line in buffers where showing the tab-line makes no sense.
> The default value of tab-line-exclude-modes is a good example of that.

Of course, but the variable names can be confusing, some users familiar
with other tab-line-like packages might expect this feature.  This may
also depend on the users workflow; some may prefer to use the tab-line
to display only relevant tabs and search for the rest with "C-x b".

> But I won't object to adding a knob to have the behavior you want, if
> Juri agrees, and there are no other objections.  However, this must be
> an opt-in behavior, by default off.

Fine, I've added it as an option.

>> Currently, it only works for 'tab-line-tabs-fixed-window-buffers'.
>
> Which IMO is a limitation that should be lifted, for this feature to
> make sense.  I expect to see bug reports if we don't.

I've added it to the other relevant functions.

>> +*** 'tab-line-tabs-fixed-window-buffers' now hides the excluded
>> tabs.
>> +All the buffers included in 'tab-line-exclude-buffers' and
>> +'tab-line-exclude-modes' will not appear in the tab line only if
>> +'tab-line-tabs-function' is set to
>> 'tab-line-tabs-fixed-window-buffers'.
>
> A buffer cannot be "included" in a list of modes, so talking about a
> buffer included in tab-line-exclude-modes is confusing.  I suggest to
> reword:
>
>   *** Excluded buffers are no longer shown in tab-lines of other buffers.
>   Buffers that match 'tab-line-exclude-buffers' and buffers whose
>   modes are in 'tab-line-exclude-modes' will not appear in tab-lines
>   of other buffers.

> Also, why isn't there either "+++" (and a suitable change to the
> manual) or "---" for this entry?  We don't want to defer the decision
> whether and how to document the changes in the manuals to the time
> when a release will be prepared, we want to make the necessary
> documentation changes right away.  So let's please decide now whether
> this change deserves to be mentioned in the manuals, and act
> accordingly.

I forgot it, but i don't think this needs to be added to the manual,
mostly because none of the NEWS entries in "Tab Bars and Tab Lines" are
in the manual.

[0001-Do-not-display-in-the-tab-line-tabs-that-are-exclude.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
- E.G via Gnus and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Mon, 04 Aug 2025 12:57:02 GMT) Full text and rfc822 format available.

Message #14 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Mon, 04 Aug 2025 15:56:26 +0300
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 79159 <at> debbugs.gnu.org
> Date: Sun, 03 Aug 2025 20:38:48 -0600
> 
> +***Excluded buffers are no longer shown in tab-lines of other buffers.
> +Buffers that match 'tab-line-exclude-buffers' and buffers whose
> +modes are in 'tab-line-exclude-modes' will not appear in tab-lines
> +of other buffers.

If the default is to show them (which is what I think we should do),
then the above should make it clear that the new behavior is optional.
As in "Excluded buffers can now be hidden from tab-lines in other buffers".

> +(defcustom tab-line-hide-excluded-buffers nil
> +  "Whether the excluded buffers should not appear in the tab line.
                                   ^^^^^^^^^^^^^^^^^^^^
"should be hidden from" is better

Let's wait for Juri to review this.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 05 Aug 2025 06:42:02 GMT) Full text and rfc822 format available.

Message #17 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 05 Aug 2025 09:31:34 +0300
> +         (or (with-current-buffer b
> +               (memq major-mode tab-line-exclude-modes))

Optimization without using 'with-current-buffer':

  (buffer-local-value 'major-mode b)

> @@ -598,7 +626,9 @@ tab-line-tabs-fixed-window-buffers
>                                (lambda (buf idx) (puthash buf idx index-table))
>                                old-buffers)
>                               index-table))
> -         (new-buffers (sort (tab-line-tabs-window-buffers)
> +         (buffer-list (tab-line-displayable-tab-list
> +                       (funcall tab-line-tabs-fixed-buffer-list-function)))

Please don't hardcode 'tab-line-displayable-tab-list'.

The proper way is to have a predicate user option with two const values:
one is a function that returns all buffers, another that omits excluded
buffers, and a slot for a user-defined custom function.

Maybe the existing 'tab-line-tabs-buffer-list-function'
should be promoted to the user option.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 05 Aug 2025 06:42:03 GMT) Full text and rfc822 format available.

Message #20 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79159 <at> debbugs.gnu.org,
 Elijah Gabe Pérez <eg642616 <at> gmail.com>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 05 Aug 2025 09:28:30 +0300
> But I won't object to adding a knob to have the behavior you want, if
> Juri agrees, and there are no other objections.  However, this must be
> an opt-in behavior, by default off.

Better to make it opt-out because currently display of excluded buffers
on the tab-line is too glitchy.  Example:

0. emacs -Q
1. M-x global-tab-line-mode RET
2. C-x b foo RET
3. C-x b SPC *bar* RET
4. C-x <left>
   Now the buffer name " *bar*" is visible on the tab-line.
5. C-x <left>
   But now " *bar*" suddenly goes away.

This is because handling of excluded buffers is hard-coded
in many window.el functions.

So not showing excluded buffers by default will avoid this snag.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 05 Aug 2025 11:37:02 GMT) Full text and rfc822 format available.

Message #23 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 05 Aug 2025 14:36:42 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Elijah Gabe Pérez <eg642616 <at> gmail.com>,
>   79159 <at> debbugs.gnu.org
> Date: Tue, 05 Aug 2025 09:28:30 +0300
> 
> > But I won't object to adding a knob to have the behavior you want, if
> > Juri agrees, and there are no other objections.  However, this must be
> > an opt-in behavior, by default off.
> 
> Better to make it opt-out because currently display of excluded buffers
> on the tab-line is too glitchy.  Example:
> 
> 0. emacs -Q
> 1. M-x global-tab-line-mode RET
> 2. C-x b foo RET
> 3. C-x b SPC *bar* RET
> 4. C-x <left>
>    Now the buffer name " *bar*" is visible on the tab-line.
> 5. C-x <left>
>    But now " *bar*" suddenly goes away.
> 
> This is because handling of excluded buffers is hard-coded
> in many window.el functions.
> 
> So not showing excluded buffers by default will avoid this snag.

If there are bugs with handling excluded buffers, I hope we can fix
them, instead of leaving them hidden behind a user option.  People who
will use that option will see those bugs exactly as all of the users
see them today, and they _will_ complain.

OTOH, since no one has yet complained about those bugs, perhaps
leaving this behavior be the default is not such a bad idea?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 05 Aug 2025 17:47:03 GMT) Full text and rfc822 format available.

Message #26 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 05 Aug 2025 20:32:06 +0300
>> 1. M-x global-tab-line-mode RET
>> 2. C-x b foo RET
>> 3. C-x b SPC *bar* RET
>> 4. C-x <left>
>>    Now the buffer name " *bar*" is visible on the tab-line.
>> 5. C-x <left>
>>    But now " *bar*" suddenly goes away.
>> 
>> This is because handling of excluded buffers is hard-coded
>> in many window.el functions.
>> 
>> So not showing excluded buffers by default will avoid this snag.
>
> If there are bugs with handling excluded buffers, I hope we can fix
> them, instead of leaving them hidden behind a user option.  People who
> will use that option will see those bugs exactly as all of the users
> see them today, and they _will_ complain.
>
> OTOH, since no one has yet complained about those bugs, perhaps
> leaving this behavior be the default is not such a bad idea?

Not bugs, just unexpected inconsistencies.  window.el doesn't
permit excluded buffers to exist in the window-prev-buffers list
that is used for tab-line.  No one complained about this problem
because it's very difficult to notice it: one moment there is
an excluded buffer on the tab-line, and the next moment it disappears.

Not showing such buffers by default will fix this inconsistency.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 05 Aug 2025 19:23:01 GMT) Full text and rfc822 format available.

Message #29 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 05 Aug 2025 22:21:47 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: eg642616 <at> gmail.com,  79159 <at> debbugs.gnu.org
> Date: Tue, 05 Aug 2025 20:32:06 +0300
> 
> >> 1. M-x global-tab-line-mode RET
> >> 2. C-x b foo RET
> >> 3. C-x b SPC *bar* RET
> >> 4. C-x <left>
> >>    Now the buffer name " *bar*" is visible on the tab-line.
> >> 5. C-x <left>
> >>    But now " *bar*" suddenly goes away.
> >> 
> >> This is because handling of excluded buffers is hard-coded
> >> in many window.el functions.
> >> 
> >> So not showing excluded buffers by default will avoid this snag.
> >
> > If there are bugs with handling excluded buffers, I hope we can fix
> > them, instead of leaving them hidden behind a user option.  People who
> > will use that option will see those bugs exactly as all of the users
> > see them today, and they _will_ complain.
> >
> > OTOH, since no one has yet complained about those bugs, perhaps
> > leaving this behavior be the default is not such a bad idea?
> 
> Not bugs, just unexpected inconsistencies.  window.el doesn't
> permit excluded buffers to exist in the window-prev-buffers list
> that is used for tab-line.  No one complained about this problem
> because it's very difficult to notice it: one moment there is
> an excluded buffer on the tab-line, and the next moment it disappears.
> 
> Not showing such buffers by default will fix this inconsistency.

No, it will just sweep the problem under the carpet.  Since when are
we handling bugs in this manner?  If a feature needs work to be
finished, let's please invest the effort to do that work.  Let's
please not have semi-broken features.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Wed, 06 Aug 2025 06:38:02 GMT) Full text and rfc822 format available.

Message #32 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Wed, 06 Aug 2025 09:28:06 +0300
>> >> 1. M-x global-tab-line-mode RET
>> >> 2. C-x b foo RET
>> >> 3. C-x b SPC *bar* RET
>> >> 4. C-x <left>
>> >>    Now the buffer name " *bar*" is visible on the tab-line.
>> >> 5. C-x <left>
>> >>    But now " *bar*" suddenly goes away.
>> >> 
>> >> This is because handling of excluded buffers is hard-coded
>> >> in many window.el functions.
>> >> 
>> >> So not showing excluded buffers by default will avoid this snag.
>> >
>> > If there are bugs with handling excluded buffers, I hope we can fix
>> > them, instead of leaving them hidden behind a user option.  People who
>> > will use that option will see those bugs exactly as all of the users
>> > see them today, and they _will_ complain.
>> >
>> > OTOH, since no one has yet complained about those bugs, perhaps
>> > leaving this behavior be the default is not such a bad idea?
>> 
>> Not bugs, just unexpected inconsistencies.  window.el doesn't
>> permit excluded buffers to exist in the window-prev-buffers list
>> that is used for tab-line.  No one complained about this problem
>> because it's very difficult to notice it: one moment there is
>> an excluded buffer on the tab-line, and the next moment it disappears.
>> 
>> Not showing such buffers by default will fix this inconsistency.
>
> No, it will just sweep the problem under the carpet.  Since when are
> we handling bugs in this manner?  If a feature needs work to be
> finished, let's please invest the effort to do that work.  Let's
> please not have semi-broken features.

Currently there is a bug in tab-line.el, and the proposed patch fixes it.

Without activating global-tab-line-mode try the following:

0. emacs -Q
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Wed, 06 Aug 2025 12:52:01 GMT) Full text and rfc822 format available.

Message #35 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Wed, 06 Aug 2025 15:51:27 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: eg642616 <at> gmail.com,  79159 <at> debbugs.gnu.org
> Date: Wed, 06 Aug 2025 09:28:06 +0300
> 
> >> >> 1. M-x global-tab-line-mode RET
> >> >> 2. C-x b foo RET
> >> >> 3. C-x b SPC *bar* RET
> >> >> 4. C-x <left>
> >> >>    Now the buffer name " *bar*" is visible on the tab-line.
> >> >> 5. C-x <left>
> >> >>    But now " *bar*" suddenly goes away.
> >> >> 
> >> >> This is because handling of excluded buffers is hard-coded
> >> >> in many window.el functions.
> >> >> 
> >> >> So not showing excluded buffers by default will avoid this snag.
> >> >
> >> > If there are bugs with handling excluded buffers, I hope we can fix
> >> > them, instead of leaving them hidden behind a user option.  People who
> >> > will use that option will see those bugs exactly as all of the users
> >> > see them today, and they _will_ complain.
> >> >
> >> > OTOH, since no one has yet complained about those bugs, perhaps
> >> > leaving this behavior be the default is not such a bad idea?
> >> 
> >> Not bugs, just unexpected inconsistencies.  window.el doesn't
> >> permit excluded buffers to exist in the window-prev-buffers list
> >> that is used for tab-line.  No one complained about this problem
> >> because it's very difficult to notice it: one moment there is
> >> an excluded buffer on the tab-line, and the next moment it disappears.
> >> 
> >> Not showing such buffers by default will fix this inconsistency.
> >
> > No, it will just sweep the problem under the carpet.  Since when are
> > we handling bugs in this manner?  If a feature needs work to be
> > finished, let's please invest the effort to do that work.  Let's
> > please not have semi-broken features.
> 
> Currently there is a bug in tab-line.el, and the proposed patch fixes it.
> 
> Without activating global-tab-line-mode try the following:
> 
> 0. emacs -Q
> 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.

If you consider the above a bug due to the fact that we show excluded
buffers, the conclusion is that we should unconditionally avoid
showing them, and the user option or a variable which controls this
has no place.  That assumes that our intent is that excluded buffers
should not be shown by any tab-line, and can only be switched to with
the likes of "C-x b".

It's your call.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Thu, 07 Aug 2025 04:21:02 GMT) Full text and rfc822 format available.

Message #38 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: "Elijah G." <eg642616 <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Wed, 06 Aug 2025 22:19:57 -0600
Juri Linkov <juri <at> linkov.net> writes:

[...]

>> No, it will just sweep the problem under the carpet.  Since when are
>> we handling bugs in this manner?  If a feature needs work to be
>> finished, let's please invest the effort to do that work.  Let's
>> please not have semi-broken features.
>
> Currently there is a bug in tab-line.el, and the proposed patch fixes
> it.
>
> Without activating global-tab-line-mode try the following:
>
> 0. emacs -Q
> 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>".

But i agree this should be an option, maybe disabled by default, since
it seems that no one had reported this as a bug before.

> > +         (or (with-current-buffer b
> > +               (memq major-mode tab-line-exclude-modes))

> Optimization without using 'with-current-buffer':

>   (buffer-local-value 'major-mode b)

Thanks, i forgot this exists.

> > @@ -598,7 +626,9 @@ tab-line-tabs-fixed-window-buffers
> >                                (lambda (buf idx) (puthash buf idx 
> > index-table))
> >                                old-buffers)
> >                               index-table))
> > -         (new-buffers (sort (tab-line-tabs-window-buffers)
> > +         (buffer-list (tab-line-displayable-tab-list
> > +                       (funcall tab-line-tabs-fixed-buffer-list-function)))

> Please don't hardcode 'tab-line-displayable-tab-list'.

> The proper way is to have a predicate user option with two const values:
> one is a function that returns all buffers, another that omits excluded
> buffers, and a slot for a user-defined custom function.

> 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.

-- 
- E.G via GNU Emacs Android port.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Thu, 07 Aug 2025 06:02:01 GMT) Full text and rfc822 format available.

Message #41 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Elijah G." <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Thu, 07 Aug 2025 09:01:22 +0300
> From: "Elijah G." <eg642616 <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  79159 <at> debbugs.gnu.org
> Date: Wed, 06 Aug 2025 22:19:57 -0600
> 
> Juri Linkov <juri <at> linkov.net> writes:
> 
> > 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>".
> 
> But i agree this should be an option, maybe disabled by default, since
> it seems that no one had reported this as a bug before.

If Juri thinks the above is a bug that your changes fix, there should
not be a user option that reveals the bug.  (I apologize for urging
you to add an option, because I didn't know Juri will consider the
current behavior a bug whose fix is not to show the buffers in
tab-line.)

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Thu, 07 Aug 2025 06:38:02 GMT) Full text and rfc822 format available.

Message #44 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: "Elijah G." <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Fri, 08 Aug 2025 19:15:01 GMT) Full text and rfc822 format available.

Message #47 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Fri, 08 Aug 2025 13:14:16 -0600
[Message part 1 (text/plain, inline)]
Juri Linkov <juri <at> linkov.net> writes:

>>> 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>"?

No, i don't use 'switch-to-prev-buffer-skip' and
'switch-to-prev-buffer-skip-regexp' because they don't work in tab-line
(from what I've tested).

>>> 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.

Here is what I have done, I'm not sure of the result.
[0001-tab-line-hide-excluded-buffers-in-the-tab-line.-Bug-.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
- E.G via Gnus and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Sun, 10 Aug 2025 18:42:02 GMT) Full text and rfc822 format available.

Message #50 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Sun, 10 Aug 2025 21:35:35 +0300
> +(defvar tab-line-tabs-window-buffers-filter-function
> +  #'tab-line-tabs-window-buffers-filter-default
> +  "Filter which buffers should be displayed in the tab line.")

Shouldn't this be defcustom?  Then you can add a const 'identity'
to allow keeping excluded buffers.

> +(defvar tab-line-tabs-window-buffers-function
> +  #'tab-line-tabs-window-buffers-default
> +  "Function for get a list of window buffers.
> +Used only for `tab-line-tabs-fixed-window-buffers'.")

I wonder why do you need another indirection.  It should be
sufficient to use tab-line-tabs-window-buffers-filter-function
in the current implementation of tab-line-tabs-window-buffers,
especially with the value 'identity' to keep current behavior.

> @@ -598,7 +626,10 @@ tab-line-tabs-fixed-window-buffers
>                                (lambda (buf idx) (puthash buf idx index-table))
>                                old-buffers)
>                               index-table))
> -         (new-buffers (sort (tab-line-tabs-window-buffers)
> +         (buffers (funcall
> +                   tab-line-tabs-window-buffers-filter-function
> +                   (funcall tab-line-tabs-window-buffers-function)))
> +         (new-buffers (sort buffers

Then the above change is not needed too.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Mon, 11 Aug 2025 02:26:01 GMT) Full text and rfc822 format available.

Message #53 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Mon, 11 Aug 2025 05:25:23 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 79159 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
> Date: Sun, 10 Aug 2025 21:35:35 +0300
> 
> > +(defvar tab-line-tabs-window-buffers-filter-function
> > +  #'tab-line-tabs-window-buffers-filter-default
> > +  "Filter which buffers should be displayed in the tab line.")
> 
> Shouldn't this be defcustom?  Then you can add a const 'identity'
> to allow keeping excluded buffers.

Didn't you say that keeping them produces buggy behavior?  If so, why
would we tempt users to produce bugs?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Mon, 11 Aug 2025 06:12:01 GMT) Full text and rfc822 format available.

Message #56 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79159 <at> debbugs.gnu.org, eg642616 <at> gmail.com
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Mon, 11 Aug 2025 09:08:00 +0300
>> > +(defvar tab-line-tabs-window-buffers-filter-function
>> > +  #'tab-line-tabs-window-buffers-filter-default
>> > +  "Filter which buffers should be displayed in the tab line.")
>> 
>> Shouldn't this be defcustom?  Then you can add a const 'identity'
>> to allow keeping excluded buffers.
>
> Didn't you say that keeping them produces buggy behavior?  If so, why
> would we tempt users to produce bugs?

It's not so simple.  Currently tab-line is disabled on these conditions:

              (string-match-p "\\` " (buffer-name))
              (memq major-mode tab-line-exclude-modes)
              (buffer-match-p tab-line-exclude-buffers (buffer-name))
              (get major-mode 'tab-line-exclude)
              (buffer-local-value 'tab-line-exclude (current-buffer)))

Buggy behavior is produced only on the first condition:
when the buffer name begins with a space.

So the default predicate should use exactly the same conditions
in the filter to hide buffers on the tab-line.

And also defcustom should provide another value to get back
almost the same behavior as current, with one exception that
buffers with names that begin with a space should be hidden too,
i.e. the second value should match only one condition:

              (string-match-p "\\` " (buffer-name))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 12 Aug 2025 04:30:02 GMT) Full text and rfc822 format available.

Message #59 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Mon, 11 Aug 2025 22:29:36 -0600
[Message part 1 (text/plain, inline)]
Juri Linkov <juri <at> linkov.net> writes:

>> +(defvar tab-line-tabs-window-buffers-function
>> +  #'tab-line-tabs-window-buffers-default
>> +  "Function for get a list of window buffers.
>> +Used only for `tab-line-tabs-fixed-window-buffers'.")
>
> I wonder why do you need another indirection.  It should be
> sufficient to use tab-line-tabs-window-buffers-filter-function
> in the current implementation of tab-line-tabs-window-buffers,
> especially with the value 'identity' to keep current behavior.

That was to add a simple way to customize the listed buffers in
'tab-line-tabs-fixed-window-buffers', not to be another filter.  I've
reverted it anyways:

[0001-tab-line-Allow-to-hide-excluded-buffers-in-the-tab-l.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
>>> > +(defvar tab-line-tabs-window-buffers-filter-function
>>> > +  #'tab-line-tabs-window-buffers-filter-default
>>> > +  "Filter which buffers should be displayed in the tab line.")
>>> 
>>> Shouldn't this be defcustom?  Then you can add a const 'identity'
>>> to allow keeping excluded buffers.
>>
>> Didn't you say that keeping them produces buggy behavior?  If so, why
>> would we tempt users to produce bugs?
>
> It's not so simple.  Currently tab-line is disabled on these conditions:
>
>               (string-match-p "\\` " (buffer-name))
>               (memq major-mode tab-line-exclude-modes)
>               (buffer-match-p tab-line-exclude-buffers (buffer-name))
>               (get major-mode 'tab-line-exclude)
>               (buffer-local-value 'tab-line-exclude (current-buffer)))
>
> Buggy behavior is produced only on the first condition:
> when the buffer name begins with a space.
>
> So the default predicate should use exactly the same conditions
> in the filter to hide buffers on the tab-line.
>
> And also defcustom should provide another value to get back
> almost the same behavior as current, with one exception that
> buffers with names that begin with a space should be hidden too,
> i.e. the second value should match only one condition:
>
>               (string-match-p "\\` " (buffer-name))

From what I have tested, buffers that start with a space are unlikely to
appear on the tab line by default, so i don't think a new value is
necessary.

-- 
- E.G via Gnus and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79159; Package emacs. (Tue, 12 Aug 2025 17:33:02 GMT) Full text and rfc822 format available.

Message #62 received at 79159 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 79159 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79159: [PATCH] Do not display in the tab line tabs that are
 excluded.
Date: Tue, 12 Aug 2025 20:31:12 +0300
close 79159 31.0.50
thanks

> That was to add a simple way to customize the listed buffers in
> 'tab-line-tabs-fixed-window-buffers', not to be another filter.  I've
> reverted it anyways:

Thanks, now pushed (after adding a defcustom version tag).




bug marked as fixed in version 31.0.50, send any further explanations to 79159 <at> debbugs.gnu.org and Elijah Gabe Pérez <eg642616 <at> gmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 12 Aug 2025 17:34:02 GMT) Full text and rfc822 format available.

This bug report was last modified 4 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.