* lisp/emacs-lisp/byte-run.el (defmacro, defun): Move from C.
[bpt/emacs.git] / lisp / emacs-lisp / macroexp.el
index 168a430..ba8f9c4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; macroexp.el --- Additional macro-expansion support -*- lexical-binding: t -*-
 ;;
-;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
 ;; Keywords: lisp, compiler, macros
@@ -65,7 +65,7 @@ result will be eq to LIST).
            (,unshared nil)
            (,tail ,shared)
            ,var ,new-el)
-       (while ,tail
+       (while (consp ,tail)
         (setq ,var (car ,tail)
               ,new-el (progn ,@body))
         (unless (eq ,var ,new-el)
@@ -128,11 +128,6 @@ Assumes the caller has bound `macroexpand-all-environment'."
                                 (cddr form))
                     (cdr form))
         form))
-      (`(defmacro ,name . ,args-and-body)
-       (push (cons name (cons 'lambda args-and-body))
-             macroexpand-all-environment)
-       (macroexpand-all-forms form 3))
-      (`(defun . ,_) (macroexpand-all-forms form 3))
       (`(,(or `defvar `defconst) . ,_) (macroexpand-all-forms form 2))
       (`(function ,(and f `(lambda . ,_)))
        (maybe-cons 'function
@@ -160,21 +155,31 @@ Assumes the caller has bound `macroexpand-all-environment'."
       ;; here, so that any code that cares about the difference will
       ;; see the same transformation.
       ;; First arg is a function:
-      (`(,(and fun (or `apply `mapcar `mapatoms `mapconcat `mapc))
+      (`(,(and fun (or `funcall `apply `mapcar `mapatoms `mapconcat `mapc))
          ',(and f `(lambda . ,_)) . ,args)
+       (byte-compile-log-warning
+        (format "%s quoted with ' rather than with #'"
+                (list 'lambda (nth 1 f) '...))
+        t)
        ;; We don't use `maybe-cons' since there's clearly a change.
        (cons fun
              (cons (macroexpand-all-1 (list 'function f))
                    (macroexpand-all-forms args))))
       ;; Second arg is a function:
       (`(,(and fun (or `sort)) ,arg1 ',(and f `(lambda . ,_)) . ,args)
+       (byte-compile-log-warning
+        (format "%s quoted with ' rather than with #'"
+                (list 'lambda (nth 1 f) '...))
+        t)
        ;; We don't use `maybe-cons' since there's clearly a change.
        (cons fun
              (cons (macroexpand-all-1 arg1)
                    (cons (macroexpand-all-1
                           (list 'function f))
                          (macroexpand-all-forms args)))))
-      ;; Macro expand compiler macros.
+      ;; Macro expand compiler macros.  This cannot be delayed to
+      ;; byte-optimize-form because the output of the compiler-macro can
+      ;; use macros.
       ;; FIXME: Don't depend on CL.
       (`(,(pred (lambda (fun)
                   (and (symbolp fun)
@@ -182,7 +187,7 @@ Assumes the caller has bound `macroexpand-all-environment'."
                            'cl-byte-compile-compiler-macro)
                        (functionp 'compiler-macroexpand))))
          . ,_)
-       (let ((newform (compiler-macroexpand form)))
+       (let ((newform (with-no-warnings (compiler-macroexpand form))))
          (if (eq form newform)
              (macroexpand-all-forms form 1)
            (macroexpand-all-1 newform))))