emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/dash 0c5c694 2/3: [-let] Allow inline &alist in cons de


From: Phillip Lord
Subject: [elpa] externals/dash 0c5c694 2/3: [-let] Allow inline &alist in cons destructuring.
Date: Tue, 06 Oct 2015 08:18:49 +0000

branch: externals/dash
commit 0c5c694affe63f72fdeab989b3bf5639c5a0d6c1
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>

    [-let] Allow inline &alist in cons destructuring.
    
    This means (a b &alist :c c) will destructure lists like (1 2 (:a
    . b) (:c . d)), such structures are often returned in org and other
    packages.
---
 dash.el         |    4 ++--
 dev/examples.el |    7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dash.el b/dash.el
index cae487e..81e12f9 100644
--- a/dash.el
+++ b/dash.el
@@ -1341,8 +1341,8 @@ SOURCE is a proper or improper list."
        ((cdr match-form)
         (cond
          ((and (symbolp (car match-form))
-               (eq (car match-form) '&keys))
-          (dash--match-kv (cons '&plist (cdr match-form)) 
(dash--match-cons-get-cdr skip-cdr source)))
+               (memq (car match-form) '(&keys &plist &alist &hash)))
+          (dash--match-kv match-form (dash--match-cons-get-cdr skip-cdr 
source)))
          ((dash--match-ignore-place-p (car match-form))
           (dash--match-cons-1 (cdr match-form) source
                               (plist-put props :skip-cdr (1+ skip-cdr))))
diff --git a/dev/examples.el b/dev/examples.el
index 5bd0bdc..bb36698 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -901,6 +901,13 @@ new list."
     (-let [(&plist 'a a) (list 'a 1 'b 2)] a) => 1
     (-let [(&plist 'a [a b]) (list 'a [1 2] 'b 3)] (list a b)) => '(1 2)
     (-let [(&plist 'a [a b] 'c c) (list 'a [1 2] 'c 3)] (list a b c)) => '(1 2 
3)
+    ;; mixing dot and &alist
+    (-let (((x y &alist 'a a 'c c) (list 1 2 '(a . b) '(e . f) '(g . h) '(c . 
d)))) (list x y a c)) => '(1 2 b d)
+    (-let (((_ _ &alist 'a a 'c c) (list 1 2 '(a . b) '(e . f) '(g . h) '(c . 
d)))) (list a c)) => '(b d)
+    (-let (((x y . (&alist 'a a 'c c)) (list 1 2 '(a . b) '(e . f) '(g . h) 
'(c . d)))) (list x y a c)) => '(1 2 b d)
+    (-let (((_ _ . (&alist 'a a 'c c)) (list 1 2 '(a . b) '(e . f) '(g . h) 
'(c . d)))) (list a c)) => '(b d)
+    (-let (((x y (&alist 'a a 'c c)) (list 1 2 '((a . b) (e . f) (g . h) (c . 
d))))) (list x y a c)) => '(1 2 b d)
+    (-let (((_ _ . ((&alist 'a a 'c c))) (list 1 2 '((a . b) (e . f) (g . h) 
(c . d))))) (list a c)) => '(b d)
     ;; test the &as form
     (-let (((items &as first . rest) (list 1 2 3))) (list first rest items)) 
=> '(1 (2 3) (1 2 3))
     (-let [(all &as [vect &as a b] bar) (list [1 2] 3)] (list a b bar vect 
all)) => '(1 2 3 [1 2] ([1 2] 3))



reply via email to

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