aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Petton2015-10-26 22:23:02 +0100
committerNicolas Petton2015-10-26 22:23:02 +0100
commit22579baf62fc5e6a4f0482172eb7a4e71d6fbcda (patch)
treef418c99ff60d6cbd734bfc0e3dfdb23bb005f654
parent5a9842c933483716a92f2c4410ce58ca829a594f (diff)
downloademacs-22579baf62fc5e6a4f0482172eb7a4e71d6fbcda.tar.gz
emacs-22579baf62fc5e6a4f0482172eb7a4e71d6fbcda.zip
* lisp/emacs-lisp/map.el: Better docstrings.
-rw-r--r--lisp/emacs-lisp/map.el23
1 files changed, 12 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index cc437e02e78..5ef51f12d96 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -45,12 +45,12 @@
45(require 'seq) 45(require 'seq)
46 46
47(pcase-defmacro map (&rest args) 47(pcase-defmacro map (&rest args)
48 "pcase pattern matching map elements. 48 "Build a `pcase' pattern matching map elements.
49 49
50Matches if the object is a map (list, hash-table or array), and 50The `pcase' pattern will match each element of PATTERN against
51each PATTERN matches the corresponding elements of the map. 51the corresponding elements of the map.
52 52
53Supernumerary elements of the map are ignored if fewer ARGS are 53Extra elements of the map are ignored if fewer ARGS are
54given, and the match does not fail. 54given, and the match does not fail.
55 55
56ARGS can be a list of the form (KEY PAT), in which case KEY in an 56ARGS can be a list of the form (KEY PAT), in which case KEY in an
@@ -92,7 +92,7 @@ Return RESULT if non-nil or the result of evaluation of the form."
92 (t (error "Unsupported map: %s" ,map-var))))) 92 (t (error "Unsupported map: %s" ,map-var)))))
93 93
94(defun map-elt (map key &optional default) 94(defun map-elt (map key &optional default)
95 "Perform a lookup in MAP of KEY and return its associated value. 95 "Lookup KEY in MAP and return its associated value.
96If KEY is not found, return DEFAULT which defaults to nil. 96If KEY is not found, return DEFAULT which defaults to nil.
97 97
98If MAP is a list, `eql' is used to lookup KEY. 98If MAP is a list, `eql' is used to lookup KEY.
@@ -122,7 +122,7 @@ MAP can be a list, hash-table or array."
122 default))) 122 default)))
123 123
124(defmacro map-put (map key value) 124(defmacro map-put (map key value)
125 "In MAP, associate KEY with VALUE and return MAP. 125 "Associate KEY with VALUE in MAP and return MAP.
126If KEY is already present in MAP, replace the associated value 126If KEY is already present in MAP, replace the associated value
127with VALUE. 127with VALUE.
128 128
@@ -133,8 +133,9 @@ MAP can be a list, hash-table or array."
133 ,map))) 133 ,map)))
134 134
135(defmacro map-delete (map key) 135(defmacro map-delete (map key)
136 "In MAP, delete the key KEY if present and return MAP. 136 "Delete KEY from MAP and return MAP.
137If MAP is an array, store nil at the index KEY. 137No error is signaled if KEY is not a key of MAP. If MAP is an
138array, store nil at the index KEY.
138 139
139MAP can be a list, hash-table or array." 140MAP can be a list, hash-table or array."
140 (declare (debug t)) 141 (declare (debug t))
@@ -245,7 +246,7 @@ MAP can be a list, hash-table or array."
245 (arrayp map))) 246 (arrayp map)))
246 247
247(defun map-empty-p (map) 248(defun map-empty-p (map)
248 "Return non-nil is MAP is empty. 249 "Return non-nil if MAP is empty.
249 250
250MAP can be a list, hash-table or array." 251MAP can be a list, hash-table or array."
251 (map--dispatch map 252 (map--dispatch map
@@ -254,7 +255,7 @@ MAP can be a list, hash-table or array."
254 :hash-table (zerop (hash-table-count map)))) 255 :hash-table (zerop (hash-table-count map))))
255 256
256(defun map-contains-key (map key &optional testfn) 257(defun map-contains-key (map key &optional testfn)
257 "Return non-nil if MAP contain the key KEY, nil otherwise. 258 "Return non-nil if MAP contain KEY, nil otherwise.
258Equality is defined by TESTFN if non-nil or by `equal' if nil. 259Equality is defined by TESTFN if non-nil or by `equal' if nil.
259 260
260MAP can be a list, hash-table or array." 261MAP can be a list, hash-table or array."
@@ -284,7 +285,7 @@ MAP can be a list, hash-table or array."
284 t)) 285 t))
285 286
286(defun map-merge (type &rest maps) 287(defun map-merge (type &rest maps)
287 "Merge into a map of type TYPE all the key/value pairs in the maps MAPS. 288 "Merge into a map of type TYPE all the key/value pairs in MAPS.
288 289
289MAP can be a list, hash-table or array." 290MAP can be a list, hash-table or array."
290 (let (result) 291 (let (result)