Misc fixes, and use lexical-binding in more files.
[bpt/emacs.git] / lisp / emacs-lisp / macroexp.el
index 168a430..55ca905 100644 (file)
@@ -131,7 +131,16 @@ Assumes the caller has bound `macroexpand-all-environment'."
       (`(defmacro ,name . ,args-and-body)
        (push (cons name (cons 'lambda args-and-body))
              macroexpand-all-environment)
-       (macroexpand-all-forms form 3))
+       (let ((n 3))
+         ;; Don't macroexpand `declare' since it should really be "expanded"
+         ;; away when `defmacro' is expanded, but currently defmacro is not
+         ;; itself a macro.  So both `defmacro' and `declare' need to be
+         ;; handled directly in bytecomp.el.
+         ;; FIXME: Maybe a simpler solution is to (defalias 'declare 'quote).
+         (while (or (stringp (nth n form))
+                    (eq (car-safe (nth n form)) 'declare))
+           (setq n (1+ n)))
+         (macroexpand-all-forms form n)))
       (`(defun . ,_) (macroexpand-all-forms form 3))
       (`(,(or `defvar `defconst) . ,_) (macroexpand-all-forms form 2))
       (`(function ,(and f `(lambda . ,_)))