aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-07-28 23:28:18 +0200
committerLars Ingebrigtsen2019-07-28 23:28:24 +0200
commitd7665ae8df47b24d297ed131eb42ebed446423a0 (patch)
tree0c8a9fbfdb2f2f0f5fc5e8b778c83b4e98013c38
parent776872766cd3af5ef68785236dcc05b378e8f267 (diff)
downloademacs-d7665ae8df47b24d297ed131eb42ebed446423a0.tar.gz
emacs-d7665ae8df47b24d297ed131eb42ebed446423a0.zip
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)])
-rw-r--r--lisp/emacs-lisp/let-alist.el2
-rw-r--r--test/lisp/emacs-lisp/let-alist-tests.el5
2 files changed, 7 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/let-alist.el b/lisp/emacs-lisp/let-alist.el
index dc54342eab6..a9bb31113b9 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 `.'."
75 ;; Return the cons cell inside a list, so it can be appended 75 ;; Return the cons cell inside a list, so it can be appended
76 ;; with other results in the clause below. 76 ;; with other results in the clause below.
77 (list (cons data (intern (replace-match "" nil nil name))))))) 77 (list (cons data (intern (replace-match "" nil nil name)))))))
78 ((vectorp data)
79 (apply #'nconc (mapcar #'let-alist--deep-dot-search data)))
78 ((not (consp data)) nil) 80 ((not (consp data)) nil)
79 ((eq (car data) 'let-alist) 81 ((eq (car data) 'let-alist)
80 ;; For nested ‘let-alist’ forms, ignore symbols appearing in the 82 ;; 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 31db4a91dcc..9c3f2a5928f 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."
95 (should (equal (let-alist--deep-dot-search '(foo .bar (let-alist .qux .baz))) 95 (should (equal (let-alist--deep-dot-search '(foo .bar (let-alist .qux .baz)))
96 '((.bar . bar) (.qux . qux))))) ; no .baz 96 '((.bar . bar) (.qux . qux))))) ; no .baz
97 97
98(ert-deftest let-alist--vectors ()
99 (should (equal (let-alist '((a . 1) (b . 2))
100 `[,(+ .a) ,(+ .a .b .b)])
101 [1 5])))
102
98;;; let-alist.el ends here 103;;; let-alist.el ends here