Subject: Re: bug#44068: 28.0.50; Faulty uses of tabulated-list-format

From: Stephen Berman <[email-masked]>
Date: Mon, 19 Oct 2020 20:20:16 +0200

On Mon, 19 Oct 2020 16:52:09 +0300 Eli Zaretskii <[email-masked]> wrote:

>> From: Stephen Berman <[email-masked]>
>> Date: Sun, 18 Oct 2020 22:00:13 +0200
>> 
>> On trying out the new tabulated-list implementation of the bookmarks
>> list I noticed that, when clicking on the File header, the sort
>> indicator is not displayed, unlike with the Bookmark header.  Then I
>> noticed that the same thing happens in the tabulated buffer list (C-x
>> C-b).  Then I grepped for all uses of tabulated-list-format in the Emacs
>> sources and found the same problem in most of them.  The reason is that
>> in these modes the width of at least one of the columns is too narrow,
>> so that tabulated-list-init-header omits the indicator.  In most cases
>> the problematic column is the final one, but in a couple of cases there
>> are also non-final too narrow columns.  And I think these bugs are due
>> to a misleading description in tabulated-list-format's doc string.  The
>> attached patch corrects the doc string and the problematic uses of
>> tabulated-list-format.  The patch also fixes a typo and tries to improve
>> column alignment in timer-list-mode: this is one of the few modes
>> derived from tabulated-list-mode whose column widths didn't need to be
>> corrected, but the alignment seemed suboptimal; however, when the header
>> line uses a variable-pitch face, the alignment is still suboptimal even
>> with the patch, and I don't know how to fix that.
>
> Instead of manually fine-tuning each column's width, wouldn't it be
> better to use the string-trim capabilities that replace excess
> characters with an ellipsis?

I'm not sure I understand your suggestion.  If you mean to truncate the
column label in the header line when displaying the sort indicator,
e.g. change "Status" to "Sta… ▼", I'm dubious it's worth the effort,
since most of the problematic cases in the Emacs sources are with the
final column, where there's always enough space, but due to the
misleading description in tabulated-list-format's doc string, many modes
have made it unnecessarily narrow, preventing the display of the sort
indicator.  So to avoid the final column being labelled e.g. either
"File" or "Fi… ▼" instead of "File ▼", it is necessary to change the
width manually anyway.  In other words, the truncation proposal would be
an addition to manual fine-tuning (for non-final columns), not a
substitute for it.  Or did you mean something else?

Steve Berman