diff options
author | Andrea Corallo <akrl@sdf.org> | 2020-02-14 23:22:10 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2020-02-14 23:22:10 +0100 |
commit | f1bc8e480cc9d4a81826b344cac06d0bad88e21e (patch) | |
tree | 6d66f34a81e5ea992838b4c56b03a79787ecd5db /lisp/emacs-lisp/map.el | |
parent | d71801ea34b0607edd02d65e2b3150ecd7c2e8fc (diff) | |
parent | 333cc6a037e3b3300ba69ea361de1f8233c50b48 (diff) | |
download | emacs-f1bc8e480cc9d4a81826b344cac06d0bad88e21e.tar.gz emacs-f1bc8e480cc9d4a81826b344cac06d0bad88e21e.tar.bz2 emacs-f1bc8e480cc9d4a81826b344cac06d0bad88e21e.zip |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'lisp/emacs-lisp/map.el')
-rw-r--r-- | lisp/emacs-lisp/map.el | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el index 67f5b3cf24e..9c23344baca 100644 --- a/lisp/emacs-lisp/map.el +++ b/lisp/emacs-lisp/map.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton <nicolas@petton.fr> ;; Keywords: convenience, map, hash-table, alist, array -;; Version: 2.0 +;; Version: 2.1 ;; Package-Requires: ((emacs "25")) ;; Package: map @@ -56,8 +56,10 @@ evaluated and searched for in the map. The match fails if for any KEY found in the map, the corresponding PAT doesn't match the value associated to the KEY. -Each element can also be a SYMBOL, which is an abbreviation of a (KEY -PAT) tuple of the form (\\='SYMBOL SYMBOL). +Each element can also be a SYMBOL, which is an abbreviation of +a (KEY PAT) tuple of the form (\\='SYMBOL SYMBOL). When SYMBOL +is a keyword, it is an abbreviation of the form (:SYMBOL SYMBOL), +useful for binding plist values. Keys in ARGS not found in the map are ignored, and the match doesn't fail." @@ -486,9 +488,12 @@ Example: (defun map--make-pcase-bindings (args) "Return a list of pcase bindings from ARGS to the elements of a map." (seq-map (lambda (elt) - (if (consp elt) - `(app (pcase--flip map-elt ,(car elt)) ,(cadr elt)) - `(app (pcase--flip map-elt ',elt) ,elt))) + (cond ((consp elt) + `(app (pcase--flip map-elt ,(car elt)) ,(cadr elt))) + ((keywordp elt) + (let ((var (intern (substring (symbol-name elt) 1)))) + `(app (pcase--flip map-elt ,elt) ,var))) + (t `(app (pcase--flip map-elt ',elt) ,elt)))) args)) (defun map--make-pcase-patterns (args) |