]> git.eshelyaron.com Git - emacs.git/commit
Allow default values in 'map-let' and the pcase 'map' form
authorEarl Hyatt <okamsn@protonmail.com>
Fri, 21 Jul 2023 01:44:41 +0000 (21:44 -0400)
committerBasil L. Contovounesios <contovob@tcd.ie>
Sun, 30 Jul 2023 13:20:27 +0000 (15:20 +0200)
commit19777b7c864f17248f279210545579001a2c99fd
tree65a76a14240d44531c6701395dda7fd29a907285
parentda608160366aaa59567b4a45b3aabb34a2370594
Allow default values in 'map-let' and the pcase 'map' form

* lisp/emacs-lisp/map.el (map-let, map)
(map--make-pcase-bindings): Add a third argument for specifying a
default value, like in 'map-elt'. (Bug#49407)

* lisp/emacs-lisp/map.el (map--make-pcase-bindings): Clarify that keys
that aren't found aren't ignored, they actually get the value
nil (unless the new default value is given).  The overall pattern can
still fail to match if the sub-pattern for the unfound key doesn't
match nil.

* test/lisp/emacs-lisp/map-tests.el (test-map-let-default)
(test-map-plist-pcase-default, test-map-pcase-matches): Add tests,
including for the above item.
lisp/emacs-lisp/map.el
test/lisp/emacs-lisp/map-tests.el