emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 8fe836a 1/3: Fix a byte-compiler error in map-put a


From: Nicolas Petton
Subject: [Emacs-diffs] master 8fe836a 1/3: Fix a byte-compiler error in map-put and map-delete
Date: Fri, 05 Jun 2015 23:26:54 +0000

branch: master
commit 8fe836abbd64a8445880184083e1a92f87ef938a
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    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.
---
 lisp/emacs-lisp/map.el |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index b10be44..897743e 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -113,11 +113,14 @@ with VALUE.
 
 MAP can be a list, hash-table or array."
   (declare (debug t))
-  `(progn
-     (map--dispatch (m ,map m)
-       :list (setq ,map (cons (cons ,key ,value) m))
-       :hash-table (puthash ,key ,value m)
-       :array (aset m ,key ,value))))
+  (let ((symbol (symbolp map)))
+    `(progn
+       (map--dispatch (m ,map m)
+         :list (if ,symbol
+                   (setq ,map (cons (cons ,key ,value) m))
+                 (error "Literal lists are not allowed, %s must be a symbol" 
',map))
+         :hash-table (puthash ,key ,value m)
+         :array (aset m ,key ,value)))))
 
 (defmacro map-delete (map key)
   "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.
 
 MAP can be a list, hash-table or array."
   (declare (debug t))
-  `(progn
-     (map--dispatch (m ,map m)
-       :list (setq ,map (map--delete-alist m ,key))
-       :hash-table (remhash ,key m)
-       :array (map--delete-array m ,key))))
+  (let ((symbol (symbolp map)))
+    `(progn
+       (map--dispatch (m ,map m)
+         :list (if ,symbol
+                   (setq ,map (map--delete-alist m ,key))
+                 (error "Literal lists are not allowed, %s must be a symbol" 
',map))
+         :hash-table (remhash ,key m)
+         :array (map--delete-array m ,key)))))
 
 (defun map-nested-elt (map keys &optional default)
   "Traverse MAP using KEYS and return the looked up value or DEFAULT if nil.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]