From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#44068: 28.0.50; Faulty uses of tabulated-list-format Date: Mon, 19 Oct 2020 00:17:12 +0200 Message-ID: <87blgzdvrr.fsf@gmx.net> References: <87imb7e242.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2989"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 44068@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 19 00:18:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUH0D-0000gV-J0 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 00:18:09 +0200 Original-Received: from localhost ([::1]:56158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUH0C-0006Ep-Km for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Oct 2020 18:18:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUH06-0006Ef-4y for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2020 18:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUH05-0004tv-RP for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2020 18:18:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kUH05-0000Om-Nt for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2020 18:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Oct 2020 22:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44068 X-GNU-PR-Package: emacs Original-Received: via spool by 44068-submit@debbugs.gnu.org id=B44068.1603059445964 (code B ref 44068); Sun, 18 Oct 2020 22:18:01 +0000 Original-Received: (at 44068) by debbugs.gnu.org; 18 Oct 2020 22:17:25 +0000 Original-Received: from localhost ([127.0.0.1]:39292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUGzU-0000FC-Oe for submit@debbugs.gnu.org; Sun, 18 Oct 2020 18:17:25 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:47277) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUGzT-0000A2-L1 for 44068@debbugs.gnu.org; Sun, 18 Oct 2020 18:17:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603059437; bh=1mY68cnEhRgPTWrAqT2wP9OZ2iTfa6tTlJUw2isOt08=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=Vfb3p9Yht7+zGZ8SWlTFCUangqknm+IdVJqAAIehjOdSnR5v/OYp2p9NIREuS4v6y pKniA3FBTIj7VtkY+Rm41EdgcVy5E6Ps4tr1T3+BS0BM5ToGxJ9e8Nn3iCKiJZeXAv x+ONtKfqZTFOihR84LAG91ZwPRu7HKor+9rIm1wU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobe-jhalfs ([178.6.223.210]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MwwZd-1kFbQE0Bi7-00yPgP; Mon, 19 Oct 2020 00:17:17 +0200 In-Reply-To: (Stefan Kangas's message of "Sun, 18 Oct 2020 15:01:31 -0700") X-Provags-ID: V03:K1:HEaZM46js9DC8puDVtIKaZiczkGmUBzOFC6vRhaAShZoetVHft7 h/DsPJH/0Ya4wovAvc/EHHxfouG0oI6jpq6iNyLy0NTiQCC/O26f34IKzIfcDeN4o2BoXip TFD/QAKC8vhYqv6U29Zc+mp0gULnR7ri/mXmHHRSrYkx785MPpkc6ojbNUrS9ZvaKk7O+cS 5CsTXdr3+MBFOYEHYERew== X-UI-Out-Filterresults: notjunk:1;V03:K0:ahyb7QvJ1l0=:vj8V4lkyidYuwtPAdpe+tX syGjdXxt4An85sjbUs1OiwkcPesm9VjdHCBCfUb7nRlPy3JQGSOTk/OaqNTI+J2HGaryrUgua 4LBQZbdU/7G/RU9rHNr4Kx7GYabJYn28wooROHkXwoEeqfoVrO9lfATphNwp57TU3oJqrv166 Ecb3SiZHpcUf2cAKMOlco9573jYbUJ8/Glr/9/F/N5mlmpN8Oq4iZbkaT75j1BlNt9SC9Y2Ud G2aOtiMHJltjGdnuYsDNIOZiiBnGbc/vBSBSLO6IeaFmfo7KnIDbSPBlzBsJ3n25P3NdgleaS S5zSlzOWSiLQGzWioXgEiyMGn0cpxBmKQrjok6Ito7NxBnF24q2n64iHi8FmrGgpvzXm2eqPa V0GV9hqTjxWCK8FUrTqBFJTXshDqGgmhe+naPqNsCffcK9XNi97JEVByt4+m/dUPOLC6vR1Ar Ac9YOQ42uBdeXfWo6fzb0pGGAW3KIJDhwvVkhWJXYXs8nfWisBAqLWWOVeaiIM64fJWv9fJwQ XocMXCo6fLfV0mkz9fzth5m3RXD7icv99JBIG3vqF1Zvry/S2eKqiArz0CnZoQg3OtvsAcOg5 0H3u2tNzqXB9byZL6NDUj1r3p9mHtgGFVI+hqfajge3I+01NhdEuyKBxUBTOq1H2lLYZDIfcs 8FbZ2tob/LKuJrYlke02msgnzQ2LC2R4Xsi9Vyun0GcHeQoKIsbgkusQEkDMK46U8HNLgU3sj WYE27Tnr4aXSgKf/yJjL5L8SAh6f8NDpZISwcLWho7dZludJVyjxq9cJE7v/AgmjgIYdA/Ps X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:190925 Archived-At: On Sun, 18 Oct 2020 15:01:31 -0700 Stefan Kangas wrote: > Stephen Berman 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