aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Petton2015-06-06 01:08:00 +0200
committerNicolas Petton2015-06-06 01:26:25 +0200
commit8fe836abbd64a8445880184083e1a92f87ef938a (patch)
tree1a936f91e5348308997869944bcd023c913386d1
parent5977a07d949a60b66d0f2310fbd4dbd06cd0b9ea (diff)
downloademacs-8fe836abbd64a8445880184083e1a92f87ef938a.tar.gz
emacs-8fe836abbd64a8445880184083e1a92f87ef938a.zip
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.
-rw-r--r--lisp/emacs-lisp/map.el26
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index b10be44c218..897743e5b10 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -113,11 +113,14 @@ with VALUE.
113 113
114MAP can be a list, hash-table or array." 114MAP can be a list, hash-table or array."
115 (declare (debug t)) 115 (declare (debug t))
116 `(progn 116 (let ((symbol (symbolp map)))
117 (map--dispatch (m ,map m) 117 `(progn
118 :list (setq ,map (cons (cons ,key ,value) m)) 118 (map--dispatch (m ,map m)
119 :hash-table (puthash ,key ,value m) 119 :list (if ,symbol
120 :array (aset m ,key ,value)))) 120 (setq ,map (cons (cons ,key ,value) m))
121 (error "Literal lists are not allowed, %s must be a symbol" ',map))
122 :hash-table (puthash ,key ,value m)
123 :array (aset m ,key ,value)))))
121 124
122(defmacro map-delete (map key) 125(defmacro map-delete (map key)
123 "In MAP, delete the key KEY if present and return MAP. 126 "In MAP, delete the key KEY if present and return MAP.
@@ -125,11 +128,14 @@ If MAP is an array, store nil at the index KEY.
125 128
126MAP can be a list, hash-table or array." 129MAP can be a list, hash-table or array."
127 (declare (debug t)) 130 (declare (debug t))
128 `(progn 131 (let ((symbol (symbolp map)))
129 (map--dispatch (m ,map m) 132 `(progn
130 :list (setq ,map (map--delete-alist m ,key)) 133 (map--dispatch (m ,map m)
131 :hash-table (remhash ,key m) 134 :list (if ,symbol
132 :array (map--delete-array m ,key)))) 135 (setq ,map (map--delete-alist m ,key))
136 (error "Literal lists are not allowed, %s must be a symbol" ',map))
137 :hash-table (remhash ,key m)
138 :array (map--delete-array m ,key)))))
133 139
134(defun map-nested-elt (map keys &optional default) 140(defun map-nested-elt (map keys &optional default)
135 "Traverse MAP using KEYS and return the looked up value or DEFAULT if nil. 141 "Traverse MAP using KEYS and return the looked up value or DEFAULT if nil.