]> git.eshelyaron.com Git - emacs.git/commit
Various map.el improvements
authorBasil L. Contovounesios <contovob@tcd.ie>
Wed, 24 Feb 2021 00:53:05 +0000 (00:53 +0000)
committerBasil L. Contovounesios <contovob@tcd.ie>
Sat, 6 Mar 2021 16:00:52 +0000 (16:00 +0000)
commitd925121b1e1cdf953705a5da43f8092f2a6e1d8c
tree8dff1301aedbba294f2d869f86bb8d4260cf5196
parent1d43c1854a5cd8305200f6cff8ff8e80cb2b4b8a
Various map.el improvements

* lisp/emacs-lisp/seq.el (seq-do-indexed): Return nil as per doc.

* lisp/emacs-lisp/map.el: Require Emacs >= 26 due to dependence on
5-arg alist-get.  Bump package to version 3.0.  Fix other
headers.  (Bug#46754)
(map--plist-p): Detect list starting with nil as plist, not alist.
(map-elt, map-filter, map-apply, map--make-pcase-bindings)
(map--make-pcase-patterns): Simplify.
(map-let, map-put, map-nested-elt, mapp): Update docstring for plist
support.
(map-delete): Fix OBOE on arrays.  Split into cl-defmethods.
(map-values, map-values-apply): Specialize for arrays.
(map-pairs, map-keys-apply, map-put!): Improve docstring.
(map-length): Clarify docstring w.r.t. duplicate keys.  Split into
cl-defmethods.  Optimize default implementation.
(map-copy): Use copy-alist on alists.  Split into cl-defmethods.
(map-contains-key): Add plist support.  Clarify docstring
w.r.t. optional argument.  Simplify default implementation.
(map-some, map-every-p, map-merge, map-merge-with, map--into-hash):
Don't use map-apply for side effects.
(map-into): Preserve plist ordering.  Improve docstrings.
(map-insert): Add hash-table and array support.
(map-inplace): Remove unused error symbol.
(map-do): Return nil as per doc.

* etc/NEWS: Announce new user-visible behavior.

* test/lisp/emacs-lisp/map-tests.el: Prefer should-not
over (should (not ...)) in general.
(with-maps-do): Fix docstring.
(with-empty-maps-do): New macro.
(test-map-elt-default, test-mapp, test-map-keys, test-map-values)
(test-map-pairs, test-map-length, test-map-copy, test-map-apply)
(test-map-do, test-map-keys-apply, test-map-values-apply)
(test-map-filter, test-map-remove, test-map-empty-p)
(test-map-contains-key, test-map-some, test-map-every-p):
Use it.

(test-map-plist-p, test-map-put!-new-keys, test-map-insert-empty)
(test-map-insert, test-map-delete-empty, test-map-copy-alist)
(test-map-contains-key-testfn, test-map-into-hash-test)
(test-map-into-empty, test-map-merge, test-map-merge-empty):
New tests.

(test-map-elt): Test array key that is within bounds but not fixnum.
(test-map-put!): Use map--plist-p.  Remove redundant tests.
(test-map-put-alist-new-key): Don't modify list literal.
(test-map-put-testfn-alist, test-map-put-return-value): Silence
obsoletion warnings.
(test-map-delete): Check for OBOE on arrays.
(test-map-delete-return-value): Remove test made redundant by
test-map-delete.
(test-map-nested-elt, test-map-into): Test plists too.
etc/NEWS
lisp/emacs-lisp/map.el
lisp/emacs-lisp/seq.el
test/lisp/emacs-lisp/map-tests.el