]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/cedet/semantic/wisent/comp.el (wisent-defcontext): Move declarations
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 15 Oct 2014 21:46:47 +0000 (17:46 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 15 Oct 2014 21:46:47 +0000 (17:46 -0400)
outside of eval-when-compile.  Use `declare'.
(wisent-with-context): Add `defvar' declarations in case this macro is
used in a file compiled with lexical-binding.
(wisent-semantic-action-expand-body): Avoid add-to-list on local var.

lisp/cedet/ChangeLog
lisp/cedet/semantic/wisent/comp.el

index 9aabc9c9e0de6fec55ee3a06c499498784af8086..2fdd1cefdcb04762c1341f29f388c00ef850d3df 100644 (file)
@@ -1,3 +1,11 @@
+2014-10-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * semantic/wisent/comp.el (wisent-defcontext): Move declarations
+       outside of eval-when-compile.  Use `declare'.
+       (wisent-with-context): Add `defvar' declarations in case this macro is
+       used in a file compiled with lexical-binding.
+       (wisent-semantic-action-expand-body): Avoid add-to-list on local var.
+
 2014-09-22  David Engster  <deng@randomsample.de>
 
        * ede/emacs.el (ede-emacs-version): Do not call 'egrep' to
index 9e25b52e8ceb0d79b248a2e3d004225cbd02a5ec..2e5d2a433950ba95733ba84e7cd9c13ae9c8e19b 100644 (file)
@@ -41,6 +41,7 @@
 
 ;;; Code:
 (require 'semantic/wisent)
+(eval-when-compile (require 'cl))
 \f
 ;;;; -------------------
 ;;;; Misc. useful things
 
 (defmacro wisent-defcontext (name &rest vars)
   "Define a context NAME that will bind variables VARS."
+  (declare (indent 1))
   (let* ((context (wisent-context-name name))
-         (bindings (mapcar #'(lambda (v) (list 'defvar v)) vars)))
-    `(eval-when-compile
-       ,@bindings
-       (defvar ,context ',vars))))
-(put 'wisent-defcontext 'lisp-indent-function 1)
+         (declarations (mapcar #'(lambda (v) (list 'defvar v)) vars)))
+    `(progn
+       ,@declarations
+       (eval-when-compile
+         (defvar ,context ',vars)))))
 
 (defmacro wisent-with-context (name &rest body)
   "Bind variables in context NAME then eval BODY."
-  `(let* ,(wisent-context-bindings name)
-     ,@body))
-(put 'wisent-with-context 'lisp-indent-function 1)
+  (declare (indent 1))
+  (let ((bindings (wisent-context-bindings name)))
+    `(progn
+       ,@(mapcar (lambda (binding) `(defvar ,(or (car-safe binding) binding)))
+                 bindings)
+       (let* ,bindings
+         ,@body))))
 
 ;; A naive implementation of data structures!  But it suffice here ;-)
 
@@ -2896,7 +2902,7 @@ references found in BODY, and XBODY is BODY expression with
       (progn
         (if (wisent-check-$N body n)
             ;; Accumulate $i symbol
-            (add-to-list 'found body))
+            (pushnew body found :test #'equal))
         (cons found body))
     ;; BODY is a list, expand inside it
     (let (xbody sexpr)
@@ -2916,7 +2922,7 @@ references found in BODY, and XBODY is BODY expression with
          ;; $i symbol
          ((wisent-check-$N sexpr n)
           ;; Accumulate $i symbol
-          (add-to-list 'found sexpr))
+          (pushnew sexpr found :test #'equal))
          )
         ;; Accumulate expanded forms
         (setq xbody (nconc xbody (list sexpr))))