From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thuna Newsgroups: gmane.emacs.bugs Subject: bug#53375: [PATCH] Account for padding and content length in, tabulated-list-widen-current-column Date: Thu, 20 Jan 2022 00:40:41 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CADC61AC02E541CE6DFE0E46" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24645"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 To: 53375@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 19 23:13:03 2022 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 1nAJCP-0006Cz-I3 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jan 2022 23:13:01 +0100 Original-Received: from localhost ([::1]:48980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAJCO-0008QV-M5 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jan 2022 17:13:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAJ3i-0005FA-Gt for bug-gnu-emacs@gnu.org; Wed, 19 Jan 2022 17:04:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAJ3i-0002vk-7J for bug-gnu-emacs@gnu.org; Wed, 19 Jan 2022 17:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAJ3h-0004kB-Vi for bug-gnu-emacs@gnu.org; Wed, 19 Jan 2022 17:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thuna Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Jan 2022 22:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53375 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164262983018212 (code B ref -1); Wed, 19 Jan 2022 22:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jan 2022 22:03:50 +0000 Original-Received: from localhost ([127.0.0.1]:55785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAJ3S-0004ja-SU for submit@debbugs.gnu.org; Wed, 19 Jan 2022 17:03:50 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:59508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAIi2-000492-5q for submit@debbugs.gnu.org; Wed, 19 Jan 2022 16:41:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAIi1-0007Df-Pn for bug-gnu-emacs@gnu.org; Wed, 19 Jan 2022 16:41:37 -0500 Original-Received: from [2a00:1450:4864:20::533] (port=40881 helo=mail-ed1-x533.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAIi0-00071W-5A for bug-gnu-emacs@gnu.org; Wed, 19 Jan 2022 16:41:37 -0500 Original-Received: by mail-ed1-x533.google.com with SMTP id a18so19521503edj.7 for ; Wed, 19 Jan 2022 13:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=0L/NhksMo0ZBIKqP5y73ewcbDUbJPNWvpYt8YECCU4s=; b=D44XduHPMNdADquS109Zs9YMXGCOKUpGpPc00tSrJk8yW1TBzdL69DeIxxTMlPuG4S LjMxrj/1ngUFpMgSL34VhvrwhwDyf0cqWh+Y3gfHkqovP6PbRLBeZQoxOIOO1C2Y/GjV wWQ56TliWf8mSXziwGft6lTRxk40oN23LM/ceEN3LUrntYARSUv+Lp4LJ6O5GMCCHzBL EXzXoTMl5mdJEvvRACp3wnbcnwvMdNMEf9kdeV0BAaCOJgMDaSV+lb6aLX5BCxbuGoTz TDKdUsVSatgTnamyNo7etx4IG7Q/xWmrOypBdbZzg0EGLwcCxlba6Rf8uPS0eQTJi+Qy 8xOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=0L/NhksMo0ZBIKqP5y73ewcbDUbJPNWvpYt8YECCU4s=; b=ncBzX6mSHpnMJQJON5JwjRArnPtxce2BjOLwcFZl1G227yDrrY6e9P0v3nwgzpXczq IEJpklSKyFAAIK/GxIOMNdiMY3FHoGtR3H2xo5pswMbWvm6eDFMUkWykBxLo61wTo28H QRt+RG71qfCDn8bFOTeQtxrutcpEoDtnALLXzQrk8iVYAB4GctQIwxD+UCXhfPu5jxcd eUc8Jx9Se0sBWWSaPUSiwOSMrmPPMTVNB0nz0E/2Wv+xPX95guGf54xlwCmetNFjdseA nhPxbRizjgdRosX1x8oD2sK4mEskvsXkl9O4IQGqNwhHqk0e4cJkJLilKrFBtZDUQ0Rb VI+g== X-Gm-Message-State: AOAM532pAkX8PO7Wf5eF9l/fqmWHqgisoOS2vvhKWowlrG7PwXGr5BF/ j90LC2qsktoB47E3qOmz3T813fATSgVoPfM7+80X3A== X-Google-Smtp-Source: ABdhPJwACmekUmMqmHFU4F8boPOjL7E75/bnpdD4UYybIqRNEDotdR0Rq2fcKOCDwKTz8i1IGGVIWw== X-Received: by 2002:a50:d55b:: with SMTP id f27mr33067725edj.168.1642628443473; Wed, 19 Jan 2022 13:40:43 -0800 (PST) Original-Received: from [192.168.1.106] ([78.184.28.253]) by smtp.gmail.com with ESMTPSA id o13sm343008edj.58.2022.01.19.13.40.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Jan 2022 13:40:42 -0800 (PST) Content-Language: en-US X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::533 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=thuna.cing@gmail.com; helo=mail-ed1-x533.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 19 Jan 2022 17:03:45 -0500 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:224637 Archived-At: This is a multi-part message in MIME format. --------------CADC61AC02E541CE6DFE0E46 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit `tabulated-list-widen-current-column' previously looked only at the width of the column as given in `tabulated-list-format' however this fails to account for both the padding and content length and as a result widens the wrong column. The issue with content length is reproducible as follows: 0. emacs -Q 1. M-x shell 2. M-x list-processes 3. C-x o 4. C-: (tabulated-list-set-col 0 (make-string 50 ?.) t) 5. M-f 6. } This patch should solve the issue however it relies on `tabulated-list-get-entry' which means it fails to work if the `tabulated-list-entry' property is not set properly.  I am unsure if this should be considered a bug on the tabulated-list end or not. --------------CADC61AC02E541CE6DFE0E46 Content-Type: text/x-patch; charset=UTF-8; name="0001-Fix-tabulated-list-widen-current-column-widening-wro.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-tabulated-list-widen-current-column-widening-wro.pa"; filename*1="tch" >From 4306519f28f5889c7fbf435c0d12b596f49a6a52 Mon Sep 17 00:00:00 2001 From: Thuna Date: Tue, 18 Jan 2022 23:51:30 +0300 Subject: [PATCH] Fix tabulated-list-widen-current-column widening wrong column * tabulated-list.el (tabulated-list-widen-current-column): Account for the padding and the content width when calculating column width. --- lisp/emacs-lisp/tabulated-list.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 4a9814b5da..32a046e0fb 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -731,6 +731,7 @@ tabulated-list-widen-current-column 1." (interactive "p") (let ((start (current-column)) + (entry (tabulated-list-get-entry)) (nb-cols (length tabulated-list-format)) (col-nb 0) (total-width 0) @@ -741,9 +742,14 @@ tabulated-list-widen-current-column (if (> start (setq total-width (+ total-width - (setq col-width - (cadr (aref tabulated-list-format - col-nb)))))) + (max (setq col-width + (cadr (aref tabulated-list-format + col-nb))) + (string-width (aref entry col-nb))) + (or (plist-get (nthcdr 3 (aref tabulated-list-format + col-nb)) + :pad-right) + 1)))) (setq col-nb (1+ col-nb)) (setq found t) (setf (cadr (aref tabulated-list-format col-nb)) -- 2.25.1 --------------CADC61AC02E541CE6DFE0E46--