emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d7665ae: Make let-alist work with vectors


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master d7665ae: Make let-alist work with vectors
Date: Sun, 28 Jul 2019 17:28:31 -0400 (EDT)

branch: master
commit d7665ae8df47b24d297ed131eb42ebed446423a0
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make let-alist work with vectors
    
    * lisp/emacs-lisp/let-alist.el (let-alist--deep-dot-search):
    Descend into vectors, too, looking for dotted variables (bug#23244).
    
    Test case:
    
    (let-alist '((a . 1) (b . 2))
      `[,(+ .a) ,(+ .a .b .b)])
---
 lisp/emacs-lisp/let-alist.el            | 2 ++
 test/lisp/emacs-lisp/let-alist-tests.el | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/lisp/emacs-lisp/let-alist.el b/lisp/emacs-lisp/let-alist.el
index dc54342..a9bb311 100644
--- a/lisp/emacs-lisp/let-alist.el
+++ b/lisp/emacs-lisp/let-alist.el
@@ -75,6 +75,8 @@ symbol, and each cdr is the same symbol without the `.'."
         ;; Return the cons cell inside a list, so it can be appended
         ;; with other results in the clause below.
         (list (cons data (intern (replace-match "" nil nil name)))))))
+   ((vectorp data)
+    (apply #'nconc (mapcar #'let-alist--deep-dot-search data)))
    ((not (consp data)) nil)
    ((eq (car data) 'let-alist)
     ;; For nested ‘let-alist’ forms, ignore symbols appearing in the
diff --git a/test/lisp/emacs-lisp/let-alist-tests.el 
b/test/lisp/emacs-lisp/let-alist-tests.el
index 31db4a9..9c3f2a5 100644
--- a/test/lisp/emacs-lisp/let-alist-tests.el
+++ b/test/lisp/emacs-lisp/let-alist-tests.el
@@ -95,4 +95,9 @@ See Bug#24641."
   (should (equal (let-alist--deep-dot-search '(foo .bar (let-alist .qux .baz)))
                  '((.bar . bar) (.qux . qux)))))  ; no .baz
 
+(ert-deftest let-alist--vectors ()
+  (should (equal (let-alist '((a . 1) (b . 2))
+                   `[,(+ .a) ,(+ .a .b .b)])
+                 [1 5])))
+
 ;;; let-alist.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]