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: Thu, 29 Oct 2020 23:48:38 +0100 Message-ID: <874kmcfy2h.fsf@rub.de> References: <87imb7e242.fsf@gmx.net> <83zh4ipbli.fsf@gnu.org> <877drm13j3.fsf@gmx.net> <831rhuoy36.fsf@gnu.org> <87y2k2yqqb.fsf@gmx.net> <87h7qori97.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="38583"; 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 Thu Oct 29 23:49:24 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 1kYGjT-0009uW-QY for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 23:49:23 +0100 Original-Received: from localhost ([::1]:37860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGjS-00036Z-TA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 18:49:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYGj8-00036Q-Ke for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 18:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYGj8-0003eK-BO for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 18:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kYGj8-0008GX-7r for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 18:49: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: Thu, 29 Oct 2020 22:49: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.160401173131751 (code B ref 44068); Thu, 29 Oct 2020 22:49:02 +0000 Original-Received: (at 44068) by debbugs.gnu.org; 29 Oct 2020 22:48:51 +0000 Original-Received: from localhost ([127.0.0.1]:55258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYGix-0008G3-D3 for submit@debbugs.gnu.org; Thu, 29 Oct 2020 18:48:51 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:46233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYGiu-0008Fp-Qo for 44068@debbugs.gnu.org; Thu, 29 Oct 2020 18:48:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604011722; bh=wEDuKTIEwYMN82a6totF43zyw6roVPq6PLWXU3yqXpY=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=Udwcx0rh//S3Vo0JqfdYlDVpVjpCoip+5rn0/HoyYVp9DiQMMfdcauq8cL+sA5xzM //7eqEnUdehio20T9YZ1LUjZqFXHMlLHjwLbf+RDoAZi+grvNdyxb9bg3kwe+oL6xo MIBbmg8u0dQYRIEK8lBDhWGe8M7caMkQUt/kCS1I= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobe-jhalfs ([178.6.218.181]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2O2W-1kWcYp3uU2-003rXs; Thu, 29 Oct 2020 23:48:42 +0100 In-Reply-To: (Stefan Kangas's message of "Thu, 29 Oct 2020 16:58:52 +0000") X-Provags-ID: V03:K1:85G5A47iI1hv8W6gaZ48lfkpvY1aVkPTLyCnUIPz86pCwVVPK5Y q31m91iOB9ZFu7qGcLAprqcrRE143c7/uNSMcvEFAr/rpxStIu/pynI2wxn/w3u3SIevMBJ F4dyD9VfrKrUJTMi1HE2cjeDCvXtWeUC4DQ21ezzcHcZEfPYXB/BOsaBgUM4Ffw69X2kjEQ C01weujn+T4NVt32fJGsQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:9KJcpBsVOJQ=:0yrAKRPxHNt3J/SppE1JV2 wKUkLVusadfwDuDQnyuyB62MF/J6AzNvoIU38fvp7djFaA8BlfLURoYtPG73yV94ulC5zme7e oOPk1K+VRdWU54WVrD9GkE+Kl7munQVFwHvLSd2jMxoUoDYcrk6vG9CBQiNUGV09B6k3XPQAz z7dAv/4VEf4jstLtblvsijByMRXXs/cAoiOJETTuatgQfFq8ELdN8DsbsrS8onQ4p4yLYU7R0 cXNCpGlwcaWeCHfP/x3HzdTDzqjHE+ELrskecaoVwy85Ygky0GpDqK0NX7YRL5iZbT1jnTgpF eV+ftSo6voEd7t/ispfcK+U3sWQTQ/bLEHQi3p3iS20dkVn+U3yqm5VQ+YE2cZbBYUbk9bTR9 ptZUfyuG0lVRprNlxSxQ+hiaNTqxv8JsMhcrdiiaQ1P3JBaaXulXaAi3DAaN0jgFHPFtUYRdm r0GtNSN3TdCLMk3D3+jm+EcFkQHriQT/DIIWQ1FDJrVbAmYLtFR1X2NdTCUUql/vAd2douuUz mIcRRzv9GSPrznfL1hNZ9qsjWku4xI9w6MhwczzAl2XHYB5zvuihSSspSSSPLnKcAcLajvFDG R6udQfFLqPBm9s9rC05L23b/+mL6HtAMoM+83efMaHme2w6GuqzqtTQZouLqLxZ8R6UJhOH5z gHhwQUxSpGlPjL9mA3XXXaKVElwNjBCyY9apf0gPkLSEMPWSLxAEfPv2owC9+vQI0Yqp7jHXR tzCfBZELL4fexPyP6UTxIRq2h3E6OpLhK6mb+9VWcX2etpz60dtOofUCMh9ODJ0cxLlZTLaT 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:192014 Archived-At: --=-=-= Content-Type: text/plain On Thu, 29 Oct 2020 16:58:52 +0000 Stefan Kangas wrote: > Stephen Berman writes: > >> 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 behavior with your patch looks like an improvement to me. How about > the case when we narrow the column but there is no sort indicator, > should we use the ellipsis then? See for example `list-buffers' when > using the narrowing commands without sorting on any of the headers. Try the attached patch; does it do what you're suggesting well enough? --=-=-= 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..4341ad4f92 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -269,42 +269,50 @@ 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)) + (lablen (length label)) + (pname label) (width (nth 1 col)) (props (nthcdr 3 col)) (pad-right (or (plist-get props :pad-right) 1)) (right-align (plist-get props :right-align)) (next-x (+ x pad-right width))) + (when (and (>= lablen 3) + (> (+ 2 lablen) width) not-last-col) + (setq label (truncate-string-to-width label (- lablen 2) + nil nil t))) (push (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) + (concat label + (cond + ((and (< lablen 3) not-last-col) "") + ((cdr tabulated-list-sort-key) (format " %c" tabulated-list-gui-sort-indicator-desc)) - (t (format " %c" + (t (format " %c" tabulated-list-gui-sort-indicator-asc)))) - 'face 'bold - 'tabulated-list-column-name label - button-props)) + '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 --=-=-= Content-Type: text/plain >> 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. > > I'm not sure I understand what you mean here, could you elaborate? I meant that in some uses of tabulated-list-mode there are columns whose default width is so narrow that, when selected for sorting, they are immediately truncated (using the patch in my previous post), e.g. the "Status" column in list-processes. And the issue is exacerbated with the current patch implementing your new suggestion: with its default width "Status" is now truncated whether selected or not. In such cases it may be better to make the default width of such columns wider, which is what my first patch did. Then with the current patch, it will still be truncated when the column is sufficiently narrowed with `{'. Steve Berman --=-=-=--