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: Tue, 20 Oct 2020 18:09:56 +0200 Message-ID: <87h7qori97.fsf@gmx.net> References: <87imb7e242.fsf@gmx.net> <83zh4ipbli.fsf@gnu.org> <877drm13j3.fsf@gmx.net> <831rhuoy36.fsf@gnu.org> <87y2k2yqqb.fsf@gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17157"; 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: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 20 18:37:41 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 1kUudo-0004MP-DV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Oct 2020 18:37:40 +0200 Original-Received: from localhost ([::1]:38046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUudn-0007Iy-DE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Oct 2020 12:37:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUuE3-0005kD-6M for bug-gnu-emacs@gnu.org; Tue, 20 Oct 2020 12:11:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUuE2-0005m6-TI for bug-gnu-emacs@gnu.org; Tue, 20 Oct 2020 12:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kUuE2-0003oZ-P6 for bug-gnu-emacs@gnu.org; Tue, 20 Oct 2020 12:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Oct 2020 16:11:02 +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.160321020914578 (code B ref 44068); Tue, 20 Oct 2020 16:11:02 +0000 Original-Received: (at 44068) by debbugs.gnu.org; 20 Oct 2020 16:10:09 +0000 Original-Received: from localhost ([127.0.0.1]:46481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUuDA-0003n4-Sx for submit@debbugs.gnu.org; Tue, 20 Oct 2020 12:10:09 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:34145) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUuD8-0003mA-9N for 44068@debbugs.gnu.org; Tue, 20 Oct 2020 12:10:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603210198; bh=0BS+p/M15zHK9sza1SvOksjRqLY5U+T0WyFmeqTdLOU=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=CYzVxbl1U5G4YItsF+db4jsAbrrw3vv/h4S1vGLeKZ9Bm7jnwRuI8GXuF6B1KvN9r kkBCcX1555BNqPkuA41aSls6K7dQ5q4MmDNUi41dRBaPayq1KycifRGNM25JWMAq9W Q9N3j10jLXXwJtt+gqg9FMcQ+IuXPLEwlZn9t8uc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobe-jhalfs ([92.73.70.92]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtOKi-1k9ejQ0rb4-00upL0; Tue, 20 Oct 2020 18:09:58 +0200 In-Reply-To: <87y2k2yqqb.fsf@gmx.net> (Stephen Berman's message of "Mon, 19 Oct 2020 21:12:44 +0200") X-Provags-ID: V03:K1:mY76N99rCeWhwigUI6y1wesr5It8hH6YayS/FOqVJ60F0RujObC TrVnSgCUvHt7Aj58Bmv4zFpbdkccFm/69rCZL2rwQznORrbJ4q72v6H5uwUa9UQMgsFyKc2 z34FFX9DgugXs84IjijERpeNc+H53i8WIXg8GrDFrW6Eg04fiYkoSuYPMSDFFGqOJhSYPQ+ kpdBsMuibPa3kCER6lehQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:0VggqEpZtb0=:zW1ST7oTuVlhqMb9U0NV6V dgOqPnoFQfYKumg8yEEHxt/osuDBMmREbpSCPTkGl8U2rVxwxU0gTEVu1EM7WC6B5tYvjRHr4 gp0vj9cvD6fP+nZSeFwcwc+OPnjosngE90bl89Rt75bf3gvpNfjzSxj4/1NzK78OT95hTyiTV n97uQnR5jY4FdnNj4pD6muC1SVedeGpPTPMnt66pUIITaoH97luGLRwc/o9nTHytAkZC3N40Y JkOR2Jaak7nQDWyanGKVZMtHOmUxdzbBH11cK6vyM5wM1vtjA5vbVR8WTRi46XytO+4Cbpm21 LYnnfluYTr1Toz2bdJXrhoNzczDXbuyZhc+R+qwl+MHJAWJ3BpUJHOa9unxoXl3w4+G9FdgOV tezit1H4tEZv5H0wcQ0dY8TJ1WHArEZHVD6hH931l34/CxX1kLmhPdKzzsbflJhTYESBObXXb xngQz5wCW/8EkBE3e+0jmloPN19jwAUcE9xBH7L4xcJDRzil41zGt17oYwDlsW0nMHJy760Br f8xV+BsezMu9Y2n4tQXq3tI+VSa3hue01tL+nZAhr6vpU/1U2L5PQeEzl4dymo2WbuirNYtsW vOfJjdgm/guqLnDi8Yv+j5UT1F/Tqwh0Nb13uuGw3KhVuKDMFUHnvxc3udtyLMClLspeX1WzU o9DaXDI2GzkD5/sMJxK4yf3yB0BpFGbFqDkXcSh0sscu6KSW2Pq1tCwEYwQxz8c6wqpc8ggQ3 nMwynlBdknOjER9oCGprgITuyRpaIZtavlhVLZCzsSen0ftz/faIXgZM2Fsc+sCEHeLlRDvg 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:191109 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, 19 Oct 2020 21:12:44 +0200 Stephen Berman = wrote: > On Mon, 19 Oct 2020 21:43:57 +0300 Eli Zaretskii wrote: > >>> From: Stephen Berman >>> Cc: 44068@debbugs.gnu.org >>> Date: Mon, 19 Oct 2020 20:20:16 +0200 >>>=20 >>> > 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? >>>=20 >>> 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=E2=80=A6 =E2=96=BC", I'm dubious it's wort= h 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=E2=80=A6 =E2=96=BC" instead of "File =E2=96=BC", it is ne= cessary 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? >> >> Yes, I meant it as an addition, which will make this issue much more >> future proof. Documentation update is definitely fine (and should >> probably go to emacs-27, not to master, right?), and adjusting the >> column widths to eliminate the ellipsis is also okay. I just don't >> want us to end with these two and nothing else. > > Ok. I can try, but anyone should feel free to beat me to it. I was wrong that adjusting column widths in tabulated-list-format is necessary: with the attached patch, when a non-final column whose label is at least 3 characters long is selected, the label will get truncated and a sort indicator added; but the final column label will never get truncated and always get a sort indicator when selected. The question remains whether the truncated display in current (non-adjusted) uses of tabulated-list-mode is acceptable: if so, the patch below is all that's needed, if not, then the adjustments in my first patch can be made as well. Those interested should try the patch with list-buffers, list-bookmarks, list-packages, list-processes, list-dynamic-libraries, org-lint and flymake-diagnostics-buffer-mode to see how the display looks. Depending on the decision about that, the doc string of tabulated-list-format should be reworked accordingly. Steve Berman --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: tabulated-list-init-header patch diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index b13f609f88..aff7f985b9 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -269,15 +269,18 @@ tabulated-list-init-header ;; FIXME: Should share code with tabulated-list-print-col! (let ((x (max tabulated-list-padding 0)) (button-props `(help-echo "Click to sort by column" - mouse-face header-line-highlight - keymap ,tabulated-list-sort-button-map)) + 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)) + (not-last-col (< n (1- len))) (label (nth 0 col)) + (pname label) (width (nth 1 col)) (props (nthcdr 3 col)) (pad-right (or (plist-get props :pad-right) 1)) @@ -287,24 +290,27 @@ tabulated-list-init-header (cond ;; An unsortable column ((not (nth 2 col)) - (propertize label 'tabulated-list-column-name label)) + (propertize label 'tabulated-list-column-name pname)) ;; The selected sort column ((equal (car col) (car tabulated-list-sort-key)) - (apply 'propertize - (concat label - (cond - ((> (+ 2 (length label)) width) "") - ((cdr tabulated-list-sort-key) - (format " %c" - tabulated-list-gui-sort-indicator-desc)) - (t (format " %c" - tabulated-list-gui-sort-indicator-asc)))) - 'face 'bold - 'tabulated-list-column-name label - button-props)) + (let* ((l (length label))) + (when (and (>= l 3) (> (+ 2 l) width) not-last-col) + (setq label (truncate-string-to-width label (- l 2) nil nil t))) + (apply 'propertize + (concat label + (cond + ((and (< l 3) not-last-col) "") + ((cdr tabulated-list-sort-key) + (format " %c" + tabulated-list-gui-sort-indicator-desc)) + (t (format " %c" + tabulated-list-gui-sort-indicator-asc)))) + 'face 'bold + 'tabulated-list-column-name pname + button-props))) ;; Unselected sortable column. (t (apply 'propertize label - 'tabulated-list-column-name label + 'tabulated-list-column-name pname button-props))) cols) (when right-align --=-=-=--