emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110102: * lisp/emacs-lisp/macroexp.e


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110102: * lisp/emacs-lisp/macroexp.el (macroexp--funcall-if-compiled): Rename from
Date: Wed, 19 Sep 2012 15:59:52 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110102
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12371
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2012-09-19 15:59:52 -0400
message:
  * lisp/emacs-lisp/macroexp.el (macroexp--funcall-if-compiled): Rename from
  macroexp--eval-if-compile.
  (macroexp--funcall-and-return, macroexp--warn-and-return): New funs.
  (macroexp--expand-all): Use them.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/macroexp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-19 17:54:59 +0000
+++ b/lisp/ChangeLog    2012-09-19 19:59:52 +0000
@@ -1,5 +1,10 @@
 2012-09-19  Stefan Monnier  <address@hidden>
 
+       * emacs-lisp/macroexp.el (macroexp--funcall-if-compiled): Rename from
+       macroexp--eval-if-compile.
+       (macroexp--funcall-and-return, macroexp--warn-and-return): New funs.
+       (macroexp--expand-all): Use them (bug#12371).
+
        * doc-view.el (doc-view-guess-paper-size)
        (doc-view-scale-bounding-box): Fix unbound `caddr'.
 
@@ -174,8 +179,8 @@
        (display-buffer-function): Mark as obsolete.
 
        * progmodes/compile.el (compilation-parse-errors): Accept list
-       values similar to font-lock-keywords (Bug#12136).  Suggested by
-       Oleksandr Manzyuk.
+       values similar to font-lock-keywords (Bug#12136).
+       Suggested by Oleksandr Manzyuk.
        (compilation-error-regexp-alist): Doc fix.
 
 2012-09-15  Glenn Morris  <address@hidden>

=== modified file 'lisp/emacs-lisp/macroexp.el'
--- a/lisp/emacs-lisp/macroexp.el       2012-09-19 16:09:43 +0000
+++ b/lisp/emacs-lisp/macroexp.el       2012-09-19 19:59:52 +0000
@@ -100,19 +100,34 @@
     (error (message "Compiler-macro error for %S: %S" (car form) err)
            form)))
 
-(defun macroexp--eval-if-compile (&rest _forms)
+(defun macroexp--funcall-if-compiled (_form)
   "Pseudo function used internally by macroexp to delay warnings.
 The purpose is to delay warnings to bytecomp.el, so they can use things
 like `byte-compile-log-warning' to get better file-and-line-number data
 and also to avoid outputting the warning during normal execution."
   nil)
-(put 'macroexp--eval-if-compile 'byte-compile
+(put 'macroexp--funcall-if-compiled 'byte-compile
      (lambda (form)
-       (mapc (lambda (x) (funcall (eval x))) (cdr form))
+       (funcall (eval (cadr form)))
        (byte-compile-constant nil)))
 
-(autoload 'byte-compile-warn-obsolete "bytecomp")
-(autoload 'byte-compile-log-warning "bytecomp")
+(defun macroexp--funcall-and-return (when-compiled when-interpreted form)
+  ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this
+  ;; macro-expansion will be processed by the byte-compiler, we check
+  ;; circumstantial evidence.
+  (if (member '(declare-function . byte-compile-macroexpand-declare-function)
+              macroexpand-all-environment)
+      `(progn
+         (macroexp--funcall-if-compiled ',when-compiled)
+         ,form)
+    (funcall when-interpreted)
+    form))
+
+(defun macroexp--warn-and-return (msg form)
+  (macroexp--funcall-and-return
+   (lambda () (byte-compile-log-warning msg t))
+   (lambda () (message "%s" msg))
+   form))
 
 (defun macroexp--expand-all (form)
   "Expand all macros in FORM.
@@ -133,9 +148,10 @@
                      (car-safe form)
                      (symbolp (car form))
                      (get (car form) 'byte-obsolete-info))
-                `(progn (macroexp--eval-if-compile
-                         (lambda () (byte-compile-warn-obsolete ',(car form))))
-                        ,new-form)
+                (macroexp--funcall-and-return
+                 (lambda () (byte-compile-warn-obsolete ',(car form)))
+                 #'ignore      ;FIXME: We should `message' something.
+                 new-form)
               new-form)))
     (pcase form
       (`(cond . ,clauses)
@@ -178,26 +194,16 @@
       ;; First arg is a function:
       (`(,(and fun (or `funcall `apply `mapcar `mapatoms `mapconcat `mapc))
          ',(and f `(lambda . ,_)) . ,args)
-       (byte-compile-log-warning
+       (macroexp--warn-and-return
         (format "%s quoted with ' rather than with #'"
                 (list 'lambda (nth 1 f) '...))
-        t)
-       ;; We don't use `macroexp--cons' since there's clearly a change.
-       (cons fun
-             (cons (macroexp--expand-all (list 'function f))
-                   (macroexp--all-forms args))))
+        (macroexp--expand-all `(,fun ,f . ,args))))
       ;; Second arg is a function:
       (`(,(and fun (or `sort)) ,arg1 ',(and f `(lambda . ,_)) . ,args)
-       (byte-compile-log-warning
+       (macroexp--warn-and-return
         (format "%s quoted with ' rather than with #'"
                 (list 'lambda (nth 1 f) '...))
-        t)
-       ;; We don't use `macroexp--cons' since there's clearly a change.
-       (cons fun
-             (cons (macroexp--expand-all arg1)
-                   (cons (macroexp--expand-all
-                          (list 'function f))
-                         (macroexp--all-forms args)))))
+        (macroexp--expand-all `(,fun ,arg1 ,f . ,args))))
       (`(,func . ,_)
        ;; Macro expand compiler macros.  This cannot be delayed to
        ;; byte-optimize-form because the output of the compiler-macro can


reply via email to

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