Subject: Re: bug#69305: outline-minor-mode for tabulated-list-mode

From: Juri Linkov <[email-masked]>
Date: Thu, 22 Feb 2024 19:30:20 +0200

>> +@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
>
> I think the way to specify ENTRIES for this customization should be
> described in more detail.  Reading the above description, even the
> idea of using ENTRIES for specifying grouping is unclear, since
> tabulated-list-entries is basically just a list of column descriptors.

But ENTRIES are described in 'tabulated-list-entries'.  Here ENTRIES
are no different from 'tabulated-list-entries' that are just
column descriptors.

>> +(defcustom Buffer-menu-group-by nil
>> +  "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'.  Also when this variable is non-nil,
>> +then `outline-minor-mode' is enabled in the Buffer Menu.  Then with the
>> +default value of `outline-regexp' you can use Outline minor mode commands
>> +to show/hide groups of buffers.
>> +The default options can group by a mode, and by a root directory of
>> +a project or just `default-directory'."
>> +  :type '(choice (const :tag "No grouping" nil)
>> +                 (function-item :tag "Group by mode"
>> +                                Buffer-menu-group-by-mode)
>> +                 (function-item :tag "Group by root"
>> +                                Buffer-menu-group-by-root)
>
> I think the description text should be "Group by project" or "Group by
> project root directory" or maybe "Group by project or directory".
> Just "by root" is too vague.

Ok, then will use "Group by project root or directory".

>> +If `tabulated-list-groups' is non-nil, each group of entries
>> +is sorted separately after printing the group header line.
>
> The part following "after printing" is IMO more confusing than
> helpful.  What will be lost if you remove it?

Oops, this was too ugly, will remove this part.

>> +(ert-deftest tabulated-list-groups ()
>> +  (with-temp-buffer
>> +    (tabulated-list-mode)
>> +    (setq tabulated-list-groups
>> +          (reverse
>> +           (seq-group-by (lambda (b) (concat "* " (aref (cadr b) 3)))
>> +                         tabulated-list--test-entries)))
>> +    (setq tabulated-list-format tabulated-list--test-format)
>> +    (setq tabulated-list-padding 7)
>> +    (tabulated-list-init-header)
>> +    (tabulated-list-print)
>
> This seems to test only the function value of tabulated-list-groups?
> What about the other form of the value?

The other forms have no functional difference.