From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73775: 30.0.90; vtable: can't handle 0 data rows Date: Thu, 31 Oct 2024 12:30:09 +0200 Message-ID: <86msik36q6.fsf@gnu.org> References: <87ttdhdymx.fsf@gmail.com> <86jzeduqlp.fsf@gnu.org> <04511bb6-0832-47af-8067-2d44ed790f52@alphapapa.net> <864j5gvah8.fsf@gnu.org> <86jzebj599.fsf@fastmail.fm> <86h69cf2aq.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9673"; mail-complaints-to="usenet@ciao.gmane.io" Cc: adam@alphapapa.net, 73775@debbugs.gnu.org, arstoffel@gmail.com To: Joost Kremers Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 31 11:31:16 2024 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 1t6SSR-0002L2-Qz for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Oct 2024 11:31:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6SSJ-0003LY-Sj; Thu, 31 Oct 2024 06:31:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6SSE-0003L0-RX for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:31:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6SSE-0006vE-JJ for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:31:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=Qsu1PZG9lVRYJzvL+nZN6PC0/u/P4HFxtArUs5gpIOM=; b=ocvpb1AFR9sSsqaCPUn91PcgJ+bCpNj2uWxHiEBVlyILixWDGEIeWqeuTS0k3hl5nLmJa2AdbZHcSDLfI88DGRNm/Lor5EruuN3UvzaHfyt+fMYjlvEExkpm3msd6qg0+PtoRGCRqJIhF0QuVt0MpKEcVKFtF3f4ukuMBA4tlvcezvpMewaNtuwFxozF2yBL7SRdZXPiFD/LbAOOzlgxxJVWnHbbdY3mGeXyFOHZBmnqsufzf6z8bSlidbNx0k2fmV6aRhJVuwsKFxUR1ckDQfucGwk5eRpmjcV/mRSnpRbCKAHOt6kf7XsaGB1soAkWbZhU5RYiWE2HX8zHy3x14g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6SSE-0002uA-EA for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2024 10:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73775 X-GNU-PR-Package: emacs Original-Received: via spool by 73775-submit@debbugs.gnu.org id=B73775.173037062511146 (code B ref 73775); Thu, 31 Oct 2024 10:31:02 +0000 Original-Received: (at 73775) by debbugs.gnu.org; 31 Oct 2024 10:30:25 +0000 Original-Received: from localhost ([127.0.0.1]:41505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6SRc-0002ti-ME for submit@debbugs.gnu.org; Thu, 31 Oct 2024 06:30:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6SRY-0002tT-NP for 73775@debbugs.gnu.org; Thu, 31 Oct 2024 06:30:23 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6SRS-0006sn-O3; Thu, 31 Oct 2024 06:30:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Qsu1PZG9lVRYJzvL+nZN6PC0/u/P4HFxtArUs5gpIOM=; b=Kzw/9nC9U9n/tHIzYMWS DWzvLJCypGzJuZ9aV2On2euX/2RnnajkVqcpOvoqhOMXR9VGMwFVit6iVd2OcxRJ4MIFbIKjWgbZz RW+/Z7Y/0j49uwdEVc9Lm0D5I4ElLKEDokiqJ2F1aTLvIUQHhjvGcRfdCYYyMiOS0L9qoLuoAEq8u 8DWnl+JbX/4f3ZxKWQDxT7lcTYZ6f/YI9CvkD7+E/Dyvmags5Kur/Q7x5bWiE1DGqIQxke3Axol6y bjOo2QkI9Yd4WvCGCc43TDjrr8V4SaoL7GJX0KsxSRjrE2jviY4K0pHhSQ8cXfMmhxCn7kajj2dHE AxaDzKIuB3uQhQ==; In-Reply-To: <86h69cf2aq.fsf@fastmail.fm> (message from Joost Kremers on Wed, 16 Oct 2024 18:19:41 +0200) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294610 Archived-At: > From: Joost Kremers > Cc: Eli Zaretskii , arstoffel@gmail.com, 73775@debbugs.gnu.org > Date: Wed, 16 Oct 2024 18:19:41 +0200 > > Hi Adam, > > Thanks for looking at this. > > On Tue, Oct 15 2024, Adam Porter wrote: > > Just a few minor suggestions: > > > > + "Compute the display widths for TABLE. > > +CACHE is TABLE's cache data as returned by `vtable--compute-cache'." > > + (let ((widths (seq-map-indexed > > + (lambda (column index) > > + (let ((width > > + (or > > + ;; Explicit widths. > > + (and (vtable-column-width column) > > + (vtable--compute-width table > > (vtable-column-width column))) > > + ;; If the vtable is empty and no explicit width > > is given, > > + ;; set its width to 0 and deal with it below. > > + (if (null cache) > > > > I may be mistaken (as I haven't examined all of the relevant code), but if > > CACHE is nil when this function is called, won't it always be null? If so, > > you could check its value once, at first, rather than each time through > > this loop. > > Unfortunately, it has to be checked anew in every iteration, because it > determines for each column individually if we need to (temporarily) set its > width to 0. It also needs to keep the following `seq-max` from erroring out > (due to `seq-map` returning `nil`). > > > + ;; If there are any zero-width columns, divide the remaining window > > + ;; width evenly over them. > > + (when (member 0 widths) > > + (let* ((combined-width (apply #'+ widths)) > > + (n-0cols (length (seq-keep #'zerop widths))) > > > > You could use SEQ-COUNT here, which would avoid consing a new list. > > There may even be a better way. If I keep track of the number of zero-width > columns in the loop above, I don't even need to count them here. I've > implemented that in the updated patch attached to this message. > > > @@ -484,3 +495,8 @@ vtable--compute-columns > > table)) > > (setf (elt numerical index) nil))) > > (vtable-columns table))) > > + ;; Check if any columns have an explicit `align' property. > > + (unless recompute > > + (dolist (column (vtable-columns table)) > > + (if (vtable-column-align column) > > + (setf (vtable-column--aligned column) t)))) > > > > This could be a WHEN instead of a "one-armed IF". :) > > Yes, sirree! (I don't really agree with the "one-armed if should be > when"-stance, but I'd be hard-pressed to say when I prefer "if" and when > "when", and it's hardly a hill I want to die on, so I made the change. 😆 ) Thanks. I wanted to install this, but at least the first patch no longer applies; could you please rebase and resubmit? When you do, please mention the bug number in all the commit log messages. > * lisp/emacs-lisp/vtable.el (vtable--compute-columns): if a column was > not created with an explicit 'align' property, allow changing this > property when the column data changes from numeric to non-numeric (or > vice versa). This makes it possible to add data to an empty table, > because in a table without data all columns are assumed to be numeric > and right-aligned. This should be reformatted according to our conventions: start with a capital letter, leave two spaces between sentences, and not to indent lines. > +** 'make-vtable' can create an empty vtable This should end in a period. Also, please mark the entry with "+++", since the manuals were updated.