GNU bug report logs - #80885
[PATCH] vtable--sort: Use new sort interface

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Augusto Stoffel <arstoffel@HIDDEN>; Keywords: patch; dated Wed, 22 Apr 2026 16:02:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Apr 2026 16:01:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 22 12:01:55 2026
Received: from localhost ([127.0.0.1]:38777 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wFa1P-00009E-6X
	for submit <at> debbugs.gnu.org; Wed, 22 Apr 2026 12:01:55 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:36090)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <arstoffel@HIDDEN>)
 id 1wFa1I-00005a-EU
 for submit <at> debbugs.gnu.org; Wed, 22 Apr 2026 12:01:49 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1wFa0X-0004jx-UX
 for bug-gnu-emacs@HIDDEN; Wed, 22 Apr 2026 12:00:58 -0400
Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1wFa0P-0000wo-Mh
 for bug-gnu-emacs@HIDDEN; Wed, 22 Apr 2026 12:00:57 -0400
Received: by mail-ej1-x62d.google.com with SMTP id
 a640c23a62f3a-ba51e69988aso719171166b.0
 for <bug-gnu-emacs@HIDDEN>; Wed, 22 Apr 2026 09:00:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1776873647; x=1777478447; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Qlr8NUDtznOENpdonjOUzCU7vrx5ajU0F8q3vbsgKHI=;
 b=MFX08MnOljpCKLtMtpyfP4e5PN2WkaD9wL9YvS63jwvOA8cadKoOI/OUhctHZiXAbc
 imI7ZgxbtNXEADh6JmMCCKENcuuABAgjBLeBQdfB44JQPzO8YrFNZdpUHMknGvHyqhyh
 pFVWz4PmT7VkUVCP65FlrZWZLh5+PIDM28KJ65Uz5i3KtXkr9yvxQoOk5j4gR6b8E18D
 Zu9Uv/WC77+FdAl6ZK0nZAkwOSWF+TIqAl2DMMuZwjfSqDV4ji8AEWHFJKofhngZ1zvB
 22dLJKDp4PJtpG/6yI9j7RWcQPhXMedBywoh0EI3+Sbs3YbQagrCQxBGd2xJswktbkoi
 Kpag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20251104; t=1776873647; x=1777478447;
 h=mime-version:message-id:date:subject:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Qlr8NUDtznOENpdonjOUzCU7vrx5ajU0F8q3vbsgKHI=;
 b=LtjTXWAbZhql+KwrGl+owR/E4DCx97pG3WrHSpCzz6JRsoX6gaKJNOqok3RLBo2vMM
 88x9IONzCApR/+C3KaVGIr9CypYFbfqYiVg8uC4HSZftaus0l65A/xwy9WADizsZGUme
 tdp9l7M/O8R02S7E08YjRLB01mteGTY9BbZRtz/XijDIZu0d0NE3/wcKQuM3FqBchWoD
 fAlmS3Gq3AZEOSx7MGewgogCq/quqD1GL3UEGFg4kVU2nx9NTBcBVUiRvjSE1Zcc9edp
 LhAsdJtiGrcRx3s/6/o/VfQLr6emuQbbT+1VYFXLc2OAYoIgBGe84rg2yGDaXx/Im1pA
 YOiA==
X-Gm-Message-State: AOJu0Yyir3PT/0sNbo+zRNlTrdl/EyH/kwE4cTsD9AYB861JADhAKre0
 qxb/KsfNs8a6eOu7zH57Bd5r6CBP0dbgXVElhUA0dM7Vu32PwMDUs+vRwokiKA==
X-Gm-Gg: AeBDieu9Mo/ug0/2A7Cpbj21s3uhJQm9sIweD/8oknbuJB2W7trcdzG5Ul7xXKNq2u9
 ogz9JoVS4HG5C+ckpPVd5rhtOA9+jtP0uL0qSaw+OBP/XbDwJgpoZPp2tItVCQ/KfLFj1E+5M9X
 9piLzG4Pm0IjuGHwkFeIGWjRy3Weehm4y3uHWjk4GVxz2YTC3SLgJ9o9NhMnuysiYL1X8WK8uP1
 cKJncLEFxOy5LgUeVnVegUIi3lpKS6H7tRDNd3xdmltocIxMaiQmkwLopwJ/uoQm//HOX+SNiBX
 7xDI+ZomGO0daUoQDh8A+U+68LNYuDX3VCYcxI1p5zqtQeEY9kkq7lIYBvHDnlqoRIk9+Sm32rA
 DUg2Y5hhDApgFwDBQpAApfpnBTyX2VOcSpiaPhh4b/HU0wkhA7pV/V3xXKlxX4RE4SPNQ8srl+p
 uO7GASvT1a1A==
X-Received: by 2002:a17:907:3f08:b0:ba7:5c47:7b32 with SMTP id
 a640c23a62f3a-ba75c4787e3mr716573466b.10.1776873647237; 
 Wed, 22 Apr 2026 09:00:47 -0700 (PDT)
Received: from ars3 ([2a02:8109:8a95:9a00::269a])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-ba455045898sm562377966b.48.2026.04.22.09.00.45
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 22 Apr 2026 09:00:46 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] vtable--sort: Use new sort interface
X-Debbugs-Cc: =?utf-8?Q?St=C3=A9phane?= Marks <shipmints@HIDDEN>,
 sbaugh@HIDDEN
Date: Wed, 22 Apr 2026 18:00:45 +0200
Message-ID: <87bjfbq91u.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::62d;
 envelope-from=arstoffel@HIDDEN; helo=mail-ej1-x62d.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Tags: patch I would really like to have a :sort-key column
 attribute in vtable. In preparation for that, this is patch to use the new
 sort calling convention in vtable--sort. One thing to note: before the patch, 
 sorting a vtable would error out if a column mixes numeric and non-numeric
 data. Now, such an error will happen more often, namely every time there
 are mixed types [...] 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (arstoffel[at]gmail.com)
 1.0 FORGED_GMAIL_RCVD      'From' gmail.com does not match 'Received'
 headers
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain

Tags: patch

I would really like to have a :sort-key column attribute in vtable.  In
preparation for that, this is patch to use the new sort calling
convention in vtable--sort.

One thing to note: before the patch, sorting a vtable would error out if
a column mixes numeric and non-numeric data.  Now, such an error will
happen more often, namely every time there are mixed types.  So that's a
slight backwards incompatibility.  I'd suggest introducing the
incompatibility and see if problems arise.

If we do decide this more strict condition is not acceptable, then let's
at least make it so sorting /never/ errors out, using a suitable :lessp
function -- one that doesn't sort nil between "nikolaus" and "nilpferd",
which is silly.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-lisp-emacs-lisp-vtable.el-vtable-sort-Use-new-sort-i.patch

From 8fa9eddc18639bf4a3a5dbc30c8081fa7445e82c Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@HIDDEN>
Date: Wed, 22 Apr 2026 15:19:16 +0200
Subject: [PATCH] * lisp/emacs-lisp/vtable.el (vtable--sort):  Use new sort
 interface

---
 lisp/emacs-lisp/vtable.el | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el
index 826ed21f6ff..fd6efc9b959 100644
--- a/lisp/emacs-lisp/vtable.el
+++ b/lisp/emacs-lisp/vtable.el
@@ -695,27 +695,10 @@ vtable--clear-cache
 
 (defun vtable--sort (table cache)
   (pcase-dolist (`(,index . ,direction) (vtable-sort-by table))
-    (let ((numerical (vtable-column--numerical
-                      (elt (vtable-columns table) index)))
-          (numcomp (if (eq direction 'descend)
-                       #'> #'<))
-          (stringcomp (if (eq direction 'descend)
-                          #'string> #'string<)))
-      (setcar cache
-              (sort (car cache)
-                    (lambda (e1 e2)
-                      (let ((c1 (elt e1 (1+ index)))
-                            (c2 (elt e2 (1+ index))))
-                        (if numerical
-                            (funcall numcomp (car c1) (car c2))
-                          (funcall
-                           stringcomp
-                           (if (stringp (car c1))
-                               (car c1)
-                             (format "%s" (car c1)))
-                           (if (stringp (car c2))
-                               (car c2)
-                             (format "%s" (car c2))))))))))))
+    (cl-callf sort (car cache)
+      :key (lambda (e) (car (elt e (1+ index))))
+      :reverse (eq direction 'descend)
+      :in-place t)))
 
 (defun vtable--indicator (table index)
   (let ((order (car (last (vtable-sort-by table)))))
-- 
2.53.0


--=-=-=--




Acknowledgement sent to Augusto Stoffel <arstoffel@HIDDEN>:
New bug report received and forwarded. Copy sent to shipmints@HIDDEN, sbaugh@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to shipmints@HIDDEN, sbaugh@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#80885; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 22 Apr 2026 16:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.