Commit graph

29 commits

Author SHA1 Message Date
Nicolas Petton
5509e2f93e Add support for gv.el in map.el
* lisp/emacs-lisp/map.el (map-elt, map-delete): Declare a gv-expander.
* lisp/emacs-lisp/map.el (map-put): Refactor using `setf' and `map-elt'.
* test/automated/map-tests.el: Update tests to work with the new
implementations of map-elt and map-put.
2015-07-09 19:49:47 +02:00
Nicolas Petton
fa52edd4c4 Revert "Define `map-elt' as a generalized variable"
This reverts commit 8b6d82d3ca.
2015-06-21 23:44:50 +02:00
Nicolas Petton
8b6d82d3ca Define `map-elt' as a generalized variable
* lisp/emacs-lisp/map.el (map-elt): Define a gv-expander.

* lisp/emacs-lisp/map.el (map--dispatch): Tighten the code.

* lisp/emacs-lisp/map.el (map-put): Redefine it as a function using a
`setf' with `map-elt'.

* test/automated/map-tests.el: Comment out `test-map-put-literal'.
2015-06-21 20:49:16 +02:00
Nicolas Petton
a94202b78a Reuse `alist-get' in map.el
* lisp/emacs-lisp/map.el (map-elt): Use `alist-get' to retrieve alist
elements.
2015-06-21 20:26:52 +02:00
Nicolas Petton
7d5c120fed * lisp/emacs-lisp/map.el (map-into): Fix a byte-compiler warning. 2015-06-16 23:04:03 +02:00
Nicolas Petton
c8dc4d6804 * lisp/emacs-lisp/map.el (map-let): Better docstring. 2015-06-15 12:43:09 +02:00
Nicolas Petton
30e518379e * lisp/emacs-lisp/map.el (map-let): Better docstring. 2015-06-06 01:54:11 +02:00
Nicolas Petton
2a54e8dfff Better syntax for the map pcase pattern
* lisp/emacs-lisp/map.el: Improves the map pcase pattern to take
bindings of the form (KEY PAT) or SYMBOL. KEY is not quoted.
2015-06-06 01:50:32 +02:00
Nicolas Petton
cd22663b85 * lisp/emacs-lisp/map.el (map--dispatch): Better docstring. 2015-06-06 01:26:25 +02:00
Nicolas Petton
431fca48a8 ; * lisp/emacs-lisp/map.el: Fix formatting. 2015-06-06 01:26:25 +02:00
Nicolas Petton
8fe836abbd Fix a byte-compiler error in map-put and map-delete
* lisp/emacs-lisp/map.el (map-put, map-delete): Ensure that `setq' is
called with a symbol.
2015-06-06 01:26:25 +02:00
Glenn Morris
b0eb66823f * lisp/emacs-lisp/map.el (map--dispatch): Move before use.
(map--delete-array): Fix typo.
2015-06-05 16:30:39 -04:00
Nicolas Petton
cfb35800a8 * lisp/emacs-lisp/map.el: Better docstring for the map pcase macro. 2015-06-04 22:26:22 +02:00
Nicolas Petton
988d721186 Add a pcase pattern for maps and `map-let' based on it
* lisp/emacs-lisp/map.el (map-let): New macro.
(map--make-pcase-bindings, map--make-pcase-patterns): New functions.
* test/automated/map-tests.el: New test for `map-let'.
2015-06-02 22:19:48 +02:00
Nicolas Petton
3fe404ca66 Improve the docstring of functions in map.el
Since a map is not a data structure but a concept, adding information
about the possible types of maps can be useful information.

* lisp/emacs-lisp/map.el: Add documentation about the type of MAP to
each public function.
2015-05-16 11:30:12 +02:00
Nicolas Petton
a5237a0499 Faster implementation of map-empty-p
* lisp/emacs-lisp/map.el (map-empty-p): Faster implementation using
specific tests depending on the type of the map.
2015-04-29 19:05:44 +02:00
Nicolas Petton
12a3ea52c4 * lisp/emacs-lisp/map.el: Better docstrings. 2015-04-29 19:01:40 +02:00
Artur Malabarba
c576ab54b5 * lisp/emacs-lisp/map.el (map-pairs): Dump redundant lambda 2015-04-25 17:27:13 +01:00
Nicolas Petton
5e52b0a076 * lisp/emacs-lisp/map.el (map--elt-list): Better docstring. 2015-04-25 16:56:19 +02:00
Nicolas Petton
40a8a12a26 * lisp/emacs-lisp/map.el (map--elt-list): Minor refactoring. 2015-04-25 16:53:09 +02:00
Nicolas Petton
62879799ea Fix a false negative in `map-elt' with alists and values being nil
* lisp/emacs-lisp/map.el (map-elt): If map is an alist and key is
found but its associated value is nil, do not return the default
value.

* test/automated/map-tests.el: Add a regression test.
2015-04-25 12:07:12 +02:00
Nicolas Petton
eea2e83138 * lisp/emacs-lisp/map.el (map--dispatch): Improve the docstring. 2015-04-24 19:33:18 +02:00
Nicolas Petton
d75151a671 Do not signal an error when trying to delete a key from an array
* lisp/emacs-lisp/map.el (map-delete): When map is an array, check if
the key is present to avoid signaling an error.

* test/automated/map-tests.el: Add a test for deleting non-existing
keys from maps.
2015-04-24 19:29:59 +02:00
Nicolas Petton
79d9757c23 * lisp/emacs-lisp/map.el: Better docstring. 2015-04-24 19:15:23 +02:00
Nicolas Petton
f37e265ea9 Minor improvement in map-elt.
* lisp/emacs-lisp/map.el (map-elt): Do not use `ignore-errors' when
doing a lookup in arrays, but check the boundaries of the array
instead.

* test/automated/map-tests.el: Adds a test for `map-elt' with arrays
and a negative integer as key.
2015-04-24 19:10:45 +02:00
Nicolas Petton
a76628fd56 * lisp/emacs-lisp/map.el (map-into): Better error message. 2015-04-18 20:07:34 +02:00
Nicolas Petton
924ea3ff9d * lisp/emacs-lisp/map.el: Removes byte-compilation warnings. 2015-04-18 20:04:17 +02:00
Nicolas Petton
35c27cd581 Throw an error when converting a map into an unknown map type
* lisp/emacs-lisp/map.el (map-into): Throw an error if type is not valid.
* test/automated/map-test.el: Add a regression test.
2015-04-18 16:35:43 +02:00
Nicolas Petton
c3acb3258d New library map.el similar to seq.el but for mapping data structures.
* test/automated/map-test.el: New file.
* lisp/emacs-lisp/map.el: New file.
2015-04-18 16:22:16 +02:00