GNU logs - #66509, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66509: 29.1.50; let-alist should support numeric indexing
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 12 Oct 2023 22:04:01 +0000
Resent-Message-ID: <handler.66509.B.169714823927609 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 66509
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 66509 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.169714823927609
          (code B ref -1); Thu, 12 Oct 2023 22:04:01 +0000
Received: (at submit) by debbugs.gnu.org; 12 Oct 2023 22:03:59 +0000
Received: from localhost ([127.0.0.1]:44403 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qr3mg-0007BD-Mf
	for submit <at> debbugs.gnu.org; Thu, 12 Oct 2023 18:03:59 -0400
Received: from lists.gnu.org ([2001:470:142::17]:34572)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qr3mb-0007Ax-AF
 for submit <at> debbugs.gnu.org; Thu, 12 Oct 2023 18:03:57 -0400
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 <sbaugh@HIDDEN>)
 id 1qr3m9-0002jP-5e
 for bug-gnu-emacs@HIDDEN; Thu, 12 Oct 2023 18:03:25 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1qr3m7-0002SH-Nn
 for bug-gnu-emacs@HIDDEN; Thu, 12 Oct 2023 18:03:24 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu, 12 Oct 2023 18:03:22 -0400
Message-ID: <iera5sn5wid.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001,
 RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
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: -0.1 (/)


It would be nice if let-alist supported indexing.  So if my alist
contained lists in some places, instead of writing:

(let-alist alist
  (let-alist (nth 0 .a)
    (let-alist (nth 3 .b)
       .c)))

I could instead write:

(let-alist alist
  .a.0.b.3.c)

A patch which does this to follow.




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: bug#66509: Acknowledgement (29.1.50; let-alist should support
 numeric indexing)
Message-ID: <handler.66509.B.169714823927609.ack <at> debbugs.gnu.org>
References: <iera5sn5wid.fsf@HIDDEN>
X-Gnu-PR-Message: ack 66509
X-Gnu-PR-Package: emacs
Reply-To: 66509 <at> debbugs.gnu.org
Date: Thu, 12 Oct 2023 22:04:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 66509 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
66509: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66509
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66509: 29.1.50; let-alist should support numeric indexing
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 12 Oct 2023 22:05:02 +0000
Resent-Message-ID: <handler.66509.B66509.169714827127713 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66509
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 66509 <at> debbugs.gnu.org
Received: via spool by 66509-submit <at> debbugs.gnu.org id=B66509.169714827127713
          (code B ref 66509); Thu, 12 Oct 2023 22:05:02 +0000
Received: (at 66509) by debbugs.gnu.org; 12 Oct 2023 22:04:31 +0000
Received: from localhost ([127.0.0.1]:44408 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qr3nD-0007Cu-7d
	for submit <at> debbugs.gnu.org; Thu, 12 Oct 2023 18:04:31 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:60919)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qr3nA-0007Ca-AT
 for 66509 <at> debbugs.gnu.org; Thu, 12 Oct 2023 18:04:30 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <iera5sn5wid.fsf@HIDDEN> (Spencer Baugh's message of
 "Thu, 12 Oct 2023 18:03:22 -0400")
References: <iera5sn5wid.fsf@HIDDEN>
Date: Thu, 12 Oct 2023 18:04:00 -0400
Message-ID: <ier7cnr5whb.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Support-numeric-indexing-in-let-alist.patch
X-Spam-Score: 0.0 (/)
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 (-)

From 28e52a343f72dddd991cafd23fea910cc5f64ac5 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu, 12 Oct 2023 18:01:46 -0400
Subject: [PATCH] Support numeric indexing in let-alist

let-alist is very useful.  But sometimes an alist contains a list in
the middle, which contains yet more alists.  Previously, this was
somewhat painful to deal with, and required something like:

(let-alist alist
  (let-alist (nth 0 .a)
    (let-alist (nth 3 .b)
       .c)))

Now, the following works:

(let-alist alist
  .a.0.b.3.c)

* lisp/emacs-lisp/let-alist.el (let-alist--access-sexp): Properly
parse numbers.
(let-alist--list-to-sexp): Use nth to handle numbers.
(let-alist): Update docs.
---
 lisp/emacs-lisp/let-alist.el | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/let-alist.el b/lisp/emacs-lisp/let-alist.el
index d9ad46b2af7..de7c087bf2a 100644
--- a/lisp/emacs-lisp/let-alist.el
+++ b/lisp/emacs-lisp/let-alist.el
@@ -36,22 +36,23 @@
 ;; symbol inside body is let-bound to their cdrs in the alist.  Dotted
 ;; symbol is any symbol starting with a `.'.  Only those present in
 ;; the body are let-bound and this search is done at compile time.
+;; A number will result in a list index.
 ;;
 ;; For instance, the following code
 ;;
 ;;   (let-alist alist
-;;     (if (and .title .body)
+;;     (if (and .title.0 .body)
 ;;         .body
 ;;       .site
 ;;       .site.contents))
 ;;
 ;; essentially expands to
 ;;
-;;   (let ((.title (cdr (assq 'title alist)))
+;;   (let ((.title.0 (nth 0 (cdr (assq 'title alist))))
 ;;         (.body  (cdr (assq 'body alist)))
 ;;         (.site  (cdr (assq 'site alist)))
 ;;         (.site.contents (cdr (assq 'contents (cdr (assq 'site alist))))))
-;;     (if (and .title .body)
+;;     (if (and .title.0 .body)
 ;;         .body
 ;;       .site
 ;;       .site.contents))
@@ -93,14 +94,17 @@ let-alist--access-sexp
     (if (string-match "\\`\\." name)
         clean
       (let-alist--list-to-sexp
-       (mapcar #'intern (nreverse (split-string name "\\.")))
+       (mapcar #'read (nreverse (split-string name "\\.")))
        variable))))
 
 (defun let-alist--list-to-sexp (list var)
   "Turn symbols LIST into recursive calls to `cdr' `assq' on VAR."
-  `(cdr (assq ',(car list)
-              ,(if (cdr list) (let-alist--list-to-sexp (cdr list) var)
-                 var))))
+  (let ((sym (car list))
+        (rest (if (cdr list) (let-alist--list-to-sexp (cdr list) var)
+                 var)))
+    (cond
+     ((numberp sym) `(nth ,sym ,rest))
+     (t `(cdr (assq ',sym ,rest))))))
 
 (defun let-alist--remove-dot (symbol)
   "Return SYMBOL, sans an initial dot."
@@ -116,22 +120,23 @@ let-alist
   "Let-bind dotted symbols to their cdrs in ALIST and execute BODY.
 Dotted symbol is any symbol starting with a `.'.  Only those present
 in BODY are let-bound and this search is done at compile time.
+A number will result in a list index.
 
 For instance, the following code
 
   (let-alist alist
-    (if (and .title .body)
+    (if (and .title.0 .body)
         .body
       .site
       .site.contents))
 
 essentially expands to
 
-  (let ((.title (cdr (assq \\='title alist)))
+  (let ((.title (nth 0 (cdr (assq \\='title alist))))
         (.body  (cdr (assq \\='body alist)))
         (.site  (cdr (assq \\='site alist)))
         (.site.contents (cdr (assq \\='contents (cdr (assq \\='site alist))))))
-    (if (and .title .body)
+    (if (and .title.0 .body)
         .body
       .site
       .site.contents))
-- 
2.39.3





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


Received: (at control) by debbugs.gnu.org; 22 Oct 2023 19:48:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 15:48:48 2023
Received: from localhost ([127.0.0.1]:48211 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1queRM-0006Xi-3H
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2023 15:48:48 -0400
Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:44286)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1queRK-0006Wu-GH
 for control <at> debbugs.gnu.org; Sun, 22 Oct 2023 15:48:47 -0400
Received: by mail-lj1-x22d.google.com with SMTP id
 38308e7fff4ca-2c5210a1515so39812811fa.0
 for <control <at> debbugs.gnu.org>; Sun, 22 Oct 2023 12:48:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1698004092; x=1698608892; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:mime-version:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=z0xvpfuA3y3TmWKKKtnaSC7oGhSl6TlGqZ1fOnP/RVU=;
 b=YcA2GxKEJEZKyeODdKvRJ9QrhO+SRAcxiwXD3RMvHwQJdIKrEaNg15DvZ1ft0nGe0v
 2ivJjfUTNUBjo8GarVpquKQhcEE7hmC1MwuZFiNcfFxLKsNYxAu4zWHfmIxdNZmQpnXx
 bV+wyXN5C4f2XxbmnCJzJzQUfRYUFlrQZ6Vcq0KAkNt5ed4/HDpmHjMj6Wfx7KiygKUF
 18cbaWU5A31J1QhGvrpA37UkziXiAZQmJhAjVW7b2vZO8X1RkcBzacub+jKQSDUb0uoD
 i8Fe2EKzVELK7oco/XlsjaKIWovkvLZNhAB/HnO908syWE6muAE5UZBPl/g/3y69p8jy
 CHbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1698004092; x=1698608892;
 h=to:subject:message-id:date:mime-version:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=z0xvpfuA3y3TmWKKKtnaSC7oGhSl6TlGqZ1fOnP/RVU=;
 b=FkMsiTc19ub8i+mH+b/BiKoaTJknKB1kT0pJKX1GvyotbDPFowLAghoKnlaIK4hZO+
 9HHhKfffHYcSTf0hf1zhN8ZAYqQBYjK5sno2sOv7GJzpNWqyEs6t9RJKkUpB0S3vB3UF
 ActantGunqKnMe5ZSJ2Fi6OL/4w31SjnA5AvuODy1UNJ3Rn/csA5XkxRgCIHfEICptXg
 wNzVH6BHdwvxJiQJIhxlmhKqvQtHo6frAmVjSxMvSyt8G9zdE1wW7jJ+gFyGn9fmSwM5
 0cxnIXRTZNhVtNQ/bWH7QhtwhdiilcQDShM2gYyxT1kKWZdbhAoqabsbbTeJagIUVU+r
 2rSg==
X-Gm-Message-State: AOJu0Yz730B/9YSmDmZAWZplicaMGhM+iEj6x6Vi96aNXVly+jfLBo6x
 sFXJsT3qyqZWVRpOVqetfQw0OWonCJUmqjmt0nbr5CpYVlc=
X-Google-Smtp-Source: AGHT+IEFB7Hne3Zamu+M1Ttc9oQpZFP9kjr29Km+ScjC4Nets36EPe/OxXcaR0YcrWzdDHR8443gYG0xTWLjfg/N3bY=
X-Received: by 2002:a05:651c:14c:b0:2c5:9a5:a1c2 with SMTP id
 c12-20020a05651c014c00b002c509a5a1c2mr5159256ljd.30.1698004091903; Sun, 22
 Oct 2023 12:48:11 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 22 Oct 2023 12:48:11 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
MIME-Version: 1.0
Date: Sun, 22 Oct 2023 12:48:11 -0700
Message-ID: <CADwFkmmMS9bDZRvZfY0-sHbzFgZTpWPt73CzyspMgHbza1_sVg@HIDDEN>
Subject: control message for bug #66509
To: control <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: control
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 (-)

severity 66509 wishlist
quit




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


Received: (at control) by debbugs.gnu.org; 16 Feb 2024 22:41:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 16 17:41:10 2024
Received: from localhost ([127.0.0.1]:60311 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rb6tK-0004FI-6f
	for submit <at> debbugs.gnu.org; Fri, 16 Feb 2024 17:41:10 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:34759)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1rb6tG-0004EZ-HH
 for control <at> debbugs.gnu.org; Fri, 16 Feb 2024 17:41:07 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: control <at> debbugs.gnu.org
Subject: control message for bug #66509
Date: Fri, 16 Feb 2024 17:40:41 -0500
Message-ID: <iersf1syqvq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1708123241;
 bh=BAduLHfR9xRjllqHvPNZeCtvk9i4ri21k44D5Ywvxzs=;
 h=From:To:Subject:Date;
 b=oUa10ytUTLPxZR7QX3+EGSdmQrT3XzQrnJAOCZP9b60VoKip6kESVLK7/59s/GhJ9
 lLjIa4bdtOxL2Yf5NtIpgckaCSG+vpqE7bfBl4T0gLnFShA2HF9drS2qL3HKD4vEFI
 ejhJlqzFUTVhcKS0P/ReeyZ4SfheflPeej9bmNwcoVvS5FJq3VffkJSimzQMjbCtXw
 49USX14zqPcv7coRZoi0GtbklpF/by2uQ0lFB+8Z+Ni1cl35J3zI1hasDXin+jL4QI
 YONQM70HVJi3yLIWE0j2uvTsdy7kzK6LsbvwgidRIcWqx5RlwWKI3a0SUU9/L++BCF
 3ukJL6kCG+tbg==
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: control
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: -2.9 (--)

tags 66509 + patch
quit






Last modified: Fri, 16 Feb 2024 22:45:01 UTC

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