unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* The tab-line "All" group
@ 2022-11-21  9:42 Gabriel
  2024-04-12 16:28 ` Juri Linkov
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel @ 2022-11-21  9:42 UTC (permalink / raw)
  To: emacs-devel

The behavior of `tab-line-tabs-buffer-group-function' when returning
nil, according to its docstring, is that the "buffer should be filtered
out".  I found it not really elucidative, though.  The actual behavior
is to display a group called "All" (currently, a hardcoded value) and
don't display any tab (for the buffers that belongs to this group, i.e.,
for cases when (funcall tab-line-tabs-buffer-group-function buffer)
returns nil).

What are the actual use-cases where the behavior of "filtering out" tabs
(i.e. to don't display) for the "All" group is useful? (i.e., to hide
tabs *only* in the "All" group when the user has explicitly enabled the
tab-line mode to actually see tabs).

Personally, I find it somewhat confusing, especially because the name
"All" might led the user to think that this group contains all tabs,
which is not true.  The name "Others"/"Rest"/etc would make more sense
in this context.  If I had to choose, I would demand
`tab-line-tabs-buffer-group-function' to always return a valid (non-nil)
group name.  If an "All" group is really useful, we can properly
implement it, i.e., to have a group that *actually* contains all tabs.

At last, when `tab-line-tabs-buffer-group-function' returns an empty
string, it adds the opposite (undocumented and unintended, I guess)
"feature": to display tabs but not the group name.  The tabs are
actually added to a group named "", but the tab name is not displayed,
since it's an empty string.  Not sure if this info is useful or if we
need to change something here, but I thought it would be nice to share.

Here is a simple snippet to play with tab-line groups:

#+begin_src emacs-lisp
(progn
  (defvar my-tab-line-group-default-value nil)

  (defun my-tab-line-group-function (buffer)
    "Group tab-line tabs by project."
    (with-current-buffer buffer
      (if-let ((project (project-current)))
          (project-root project)
        my-tab-line-group-default-value)))

  (setopt tab-line-tabs-function 'tab-line-tabs-buffer-groups
          tab-line-tabs-buffer-group-function #'my-tab-line-group-function)

  (global-tab-line-mode 1))
#+end_src



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: The tab-line "All" group
  2022-11-21  9:42 The tab-line "All" group Gabriel
@ 2024-04-12 16:28 ` Juri Linkov
  0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2024-04-12 16:28 UTC (permalink / raw)
  To: Gabriel; +Cc: emacs-devel

> The behavior of `tab-line-tabs-buffer-group-function' when returning
> nil, according to its docstring, is that the "buffer should be filtered
> out".  I found it not really elucidative, though.  The actual behavior
> is to display a group called "All" (currently, a hardcoded value) and
> don't display any tab (for the buffers that belongs to this group, i.e.,
> for cases when (funcall tab-line-tabs-buffer-group-function buffer)
> returns nil).
>
> What are the actual use-cases where the behavior of "filtering out" tabs
> (i.e. to don't display) for the "All" group is useful? (i.e., to hide
> tabs *only* in the "All" group when the user has explicitly enabled the
> tab-line mode to actually see tabs).

Sorry for the delay.  Some string is needed to display to not leave
the tab-line completely empty.

> Personally, I find it somewhat confusing, especially because the name
> "All" might led the user to think that this group contains all tabs,
> which is not true.  The name "Others"/"Rest"/etc would make more sense
> in this context.  If I had to choose, I would demand
> `tab-line-tabs-buffer-group-function' to always return a valid (non-nil)
> group name.

You are right, the "All" group is too confusing.  A proper name would be
"No group" or "Ungrouped".  "No group" is shorter, so let's use it.

> If an "All" group is really useful, we can properly
> implement it, i.e., to have a group that *actually* contains all tabs.

No need to implement an "All" group explicitly since a customized
tab-line-tabs-buffer-group-function can return the string "All"
for all ungrouped buffers.

> At last, when `tab-line-tabs-buffer-group-function' returns an empty
> string, it adds the opposite (undocumented and unintended, I guess)
> "feature": to display tabs but not the group name.  The tabs are
> actually added to a group named "", but the tab name is not displayed,
> since it's an empty string.  Not sure if this info is useful or if we
> need to change something here, but I thought it would be nice to share.

Thanks for sharing.  Maybe someone might need to show no group name
for some "default group".

> Here is a simple snippet to play with tab-line groups:
>
> #+begin_src emacs-lisp
> (progn
>   (defvar my-tab-line-group-default-value nil)
>
>   (defun my-tab-line-group-function (buffer)
>     "Group tab-line tabs by project."
>     (with-current-buffer buffer
>       (if-let ((project (project-current)))
>           (project-root project)
>         my-tab-line-group-default-value)))
>
>   (setopt tab-line-tabs-function 'tab-line-tabs-buffer-groups
>           tab-line-tabs-buffer-group-function #'my-tab-line-group-function)
>
>   (global-tab-line-mode 1))
> #+end_src

Thanks for suggesting a group by project name.  This will be added now
as a new option to 'tab-line-tabs-buffer-group-function'.

PS: maybe also will add a new option 'prev-buffers'
to 'tab-line-tabs-buffer-group-sort-function'
to sort buffers by the fixed order of their
appearance in the window using information
from window prev/next buffers.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-12 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21  9:42 The tab-line "All" group Gabriel
2024-04-12 16:28 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).