unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 69305@debbugs.gnu.org
Subject: bug#69305: outline-minor-mode for tabulated-list-mode
Date: Thu, 29 Feb 2024 09:45:00 +0200	[thread overview]
Message-ID: <8634tbn2or.fsf@mail.linkov.net> (raw)
In-Reply-To: <864jdsu6ld.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Feb 2024 14:16:30 +0200")

>> >> >> But tabulated-list-groups is not a defcustom.
>> >> >> There are no defcustoms here.
>> >> >
>> >> > Buffer-menu-group-by _is_ a defcustom, and it is documented thusly:
>> >> >
>> >> >   +  "If non-nil, buffers are grouped by function.
>> >> >   +This function takes one argument: a list of entries in the same format
>> >> >   +as in `tabulated-list-entries', and should return a list in the format
>> >> >   +suitable for `tabulated-list-groups'.
>> >> >
>> >> > So you are inviting users to write functions that return values of a
>> >> > certain format, but the format's documentation IMO doesn't make it
>> >> > clear how to specify a grouping, and for its important part alludes to
>> >> > another variable (tabulated-list-entries), whose documentation is
>> >> > suitable for different kind of uses, not for grouping of entries.
>> >>
>> >> The format 'tabulated-list-entries' is input.
>> >> The format 'tabulated-list-groups' is output.
>> >
>> > Yes, I'm well aware of that.
>> >
>> >> > Since tabulated-list-groups is such an important part of the
>> >> > documentation of Buffer-menu-group-by, the doc string of
>> >> > tabulated-list-groups is in effect part of the doc string of
>> >> > Buffer-menu-group-by, and should IMO be worded as appropriate for user
>> >> > options.
>> >>
>> >> The docstring of 'tabulated-list-groups' already
>> >> sufficiently documents the format:
>> >
>> > No, it doesn't document it sufficiently.  As I already said several
>> > times.
>> >
>> >>   (defvar-local tabulated-list-groups nil
>> >>     "Groups displayed in the current Tabulated List buffer.
>> >>   This should be either a function, or a list.
>> >>   If a list, each element has the form (GROUP-NAME ENTRIES),
>> >>   where:
>> >>
>> >>    - GROUP-NAME is a group name as a string, which is displayed
>> >>      at the top line of each group.
>> >>
>> >>    - ENTRIES is a list described in `tabulated-list-entries'.
>> >>
>> >> There is no need to duplicate the description of linked
>> >> 'tabulated-list-entries'.
>> >
>> > This is not about duplication.  This is about adding information that
>> > currently isn't there.
>> >
>> >> And here it's clear that the function should add GROUP-NAME to
>> >> groups from 'tabulated-list-entries'.
>> >
>> > Which doesn't clarify the issue at hand even a single bit.
>>
>> Sorry, I don't understand what is missing here.
>> Please show an example of changes that you want.
>
> Sorry, I cannot show an example of something whose use I don't
> understand.  Which is why I asked _you_ to show an example: how to set
> up Buffer-menu-group-by to group buffers by major-mode.

Ah, you wanted to include a buffer example in "Tabulated List Mode".
Ok, here it is:

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 630e42e6878..e79b73eb081 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1246,6 +1246,41 @@ Tabulated List Mode
 above form when called with no arguments.
 @end defvar
 
+@defvar tabulated-list-groups
+This buffer-local variable specifies the groups of entries displayed in
+the Tabulated List buffer.  Its value should be either a list, or a
+function.
+
+If the value is a list, each list element corresponds to one group, and
+should have the form @w{@code{(@var{group-name} @var{entries})}}, where
+@var{group-name} is a string inserted before all group entries, and
+@var{entries} have the same format as @code{tabulated-list-entries}
+(see above).
+
+Otherwise, the value should be a function which returns a list of the
+above form when called with no arguments.
+@end defvar
+
+You can use @code{seq-group-by} to create @code{tabulated-list-groups}
+from @code{tabulated-list-entries}.  For example:
+
+@smallexample
+@group
+  (setq tabulated-list-groups
+        (seq-group-by 'Buffer-menu-group-by-mode
+                      tabulated-list-entries))
+@end group
+@end smallexample
+
+where you can define @code{Buffer-menu-group-by-mode} like this:
+
+@smallexample
+@group
+(defun Buffer-menu-group-by-mode (entry)
+  (concat "* " (aref (cadr entry) 5)))
+@end group
+@end smallexample
+
 @defvar tabulated-list-revert-hook
 This normal hook is run prior to reverting a Tabulated List buffer.  A
 derived mode can add a function to this hook to recompute





  reply	other threads:[~2024-02-29  7:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 17:34 bug#69305: outline-minor-mode for tabulated-list-mode Juri Linkov
2024-02-21 19:12 ` Eli Zaretskii
2024-02-22  7:44   ` Juri Linkov
2024-02-22  8:20     ` Eli Zaretskii
2024-02-22 17:30       ` Juri Linkov
2024-02-22 19:10         ` Eli Zaretskii
2024-02-23  7:09           ` Juri Linkov
2024-02-23  8:13             ` Eli Zaretskii
2024-02-24 17:43               ` Juri Linkov
2024-02-24 18:09                 ` Eli Zaretskii
2024-02-24 18:13                 ` Eli Zaretskii
2024-02-25  8:00                   ` Adam Porter
2024-02-25 17:25                   ` Juri Linkov
2024-02-25 19:17                     ` Eli Zaretskii
2024-02-27  7:30                       ` Juri Linkov
2024-02-27  8:31                         ` Eli Zaretskii
2024-02-27 17:40                           ` Juri Linkov
2024-02-27 18:44                             ` Eli Zaretskii
2024-02-28  7:36                               ` Juri Linkov
2024-02-28 12:16                                 ` Eli Zaretskii
2024-02-29  7:45                                   ` Juri Linkov [this message]
2024-02-29 16:33                                     ` Eli Zaretskii
2024-02-29 17:50                                       ` Juri Linkov
2024-03-03  6:53                                         ` Jean Louis
2024-03-03  7:52                                           ` Juri Linkov
2024-02-24 18:06     ` Ihor Radchenko
2024-02-24 18:16       ` Eli Zaretskii
2024-02-24 18:36         ` Ihor Radchenko
2024-02-24 18:49           ` Eli Zaretskii
2024-02-25  7:45             ` Adam Porter
2024-02-25 17:36               ` Juri Linkov
2024-02-26  3:31                 ` Adam Porter
2024-03-06 17:37                   ` Juri Linkov
2024-03-08 23:13                     ` Adam Porter
2024-02-25  7:53             ` Adam Porter
2024-02-25  8:26               ` Eli Zaretskii
2024-02-25 17:20       ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8634tbn2or.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=69305@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).