unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: 44068@debbugs.gnu.org
Subject: bug#44068: 28.0.50; Faulty uses of tabulated-list-format
Date: Mon, 19 Oct 2020 00:17:12 +0200	[thread overview]
Message-ID: <87blgzdvrr.fsf@gmx.net> (raw)
In-Reply-To: <CADwFkm=rrwXSPfiiJgWDzyae8W6AMfuLyLO_2p=DRgHbiJf19w@mail.gmail.com> (Stefan Kangas's message of "Sun, 18 Oct 2020 15:01:31 -0700")

On Sun, 18 Oct 2020 15:01:31 -0700 Stefan Kangas <stefankangas@gmail.com> wrote:

> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> 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.
>
> Your analysis sounds correct to me.
>
>> 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.
>
> Thanks for the patch.  I've tested it and it indeed fixes several bugs
> in this area.
>
> But it got me thinking: for the final column at least, maybe we should
> just make tabulated-list-mode work as advertised, and itself figure out
> that it should use this length?  That way, we would solve any bugs also
> for external packages that have been misled by the doc string.  Or would
> that have any downsides?

That was my first thought when I noticed the problem, and came up with
this patch to fix it:

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index b13f609f88..d6bec72ade 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -271,11 +271,12 @@ tabulated-list-init-header
 	(button-props `(help-echo "Click to sort by column"
 			mouse-face header-line-highlight
 			keymap ,tabulated-list-sort-button-map))
+        (len (length tabulated-list-format))
 	(cols nil))
     (if display-line-numbers
         (setq x (+ x (tabulated-list-line-number-width))))
     (push (propertize " " 'display `(space :align-to ,x)) cols)
-    (dotimes (n (length tabulated-list-format))
+    (dotimes (n len)
       (let* ((col (aref tabulated-list-format n))
 	     (label (nth 0 col))
 	     (width (nth 1 col))
@@ -293,7 +294,11 @@ tabulated-list-init-header
 	   (apply 'propertize
 		  (concat label
 			  (cond
-			   ((> (+ 2 (length label)) width) "")
+			   ((and (> (+ 2 (length label)) width)
+                                 (not (= (tabulated-list--column-number
+                                          (car tabulated-list-sort-key))
+                                         (1- len))))
+                                 "")
 			   ((cdr tabulated-list-sort-key)
                             (format " %c"
                                     tabulated-list-gui-sort-indicator-desc))

But after I saw that final (rightmost) column in the problematic cases
was simply given too narrow a width, I thought it better to just change
that and clarify the doc.  But maybe you're right that the misleading
doc has affected third-party packages.

Steve Berman





  reply	other threads:[~2020-10-18 22:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-18 20:00 bug#44068: 28.0.50; Faulty uses of tabulated-list-format Stephen Berman
2020-10-18 21:33 ` Drew Adams
2020-10-18 22:01   ` Stefan Kangas
2020-10-18 22:15     ` Drew Adams
2020-10-18 22:18     ` Stephen Berman
2020-10-18 22:01 ` Stefan Kangas
2020-10-18 22:17   ` Stephen Berman [this message]
2020-10-18 22:35     ` Stephen Berman
2020-10-18 23:13       ` Stefan Kangas
2020-10-19  9:04         ` Stephen Berman
2020-10-19 13:52 ` Eli Zaretskii
2020-10-19 18:20   ` Stephen Berman
2020-10-19 18:43     ` Eli Zaretskii
2020-10-19 19:12       ` Stephen Berman
2020-10-20 16:09         ` Stephen Berman
2020-10-29 16:58           ` Stefan Kangas
2020-10-29 22:48             ` Stephen Berman
2020-10-30  1:06               ` Stefan Kangas
2020-10-30 21:44                 ` Stephen Berman
2020-10-30 23:51                   ` Stefan Kangas
2020-11-01 23:07                     ` Stephen Berman
2020-11-02 17:12                       ` Eli Zaretskii
2020-11-02 22:37                         ` Stephen Berman
2020-11-03  3:27                           ` Eli Zaretskii
2020-11-03 23:12                             ` Stephen Berman
2020-11-04 15:09                               ` Eli Zaretskii
2020-11-04 22:55                                 ` Stephen Berman
2020-11-04 12:02                       ` Stefan Kangas
2020-11-04 22:53                         ` Stephen Berman
2020-11-12 16:38                           ` Stefan Kangas
2020-11-12 22:51                             ` Stephen Berman

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=87blgzdvrr.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=44068@debbugs.gnu.org \
    --cc=stefankangas@gmail.com \
    /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).