bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12610: unable to use macro in defadvice


From: Stefan Monnier
Subject: bug#12610: unable to use macro in defadvice
Date: Fri, 12 Oct 2012 09:35:09 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> -               `(advice lambda ,arglist ,@body)))
> +               `(advice lambda ,arglist ,@(macroexpand-all body))))

I'd rather not do such things manually.  Instead, we should expose the
code as code rather than hide it as data, so that macro-expansion
can take place without calling it explicitly and so the byte-compiler
gets to see the code, optimize it and emit warnings where needed.

I.e. I think the patch should start more along the lines of the one
below (100% guaranteed untested).


        Stefan


=== modified file 'lisp/emacs-lisp/advice.el'
--- lisp/emacs-lisp/advice.el   2012-09-14 13:44:31 +0000
+++ lisp/emacs-lisp/advice.el   2012-10-12 13:25:22 +0000
@@ -3655,13 +3655,13 @@
                      (t (error "defadvice: Invalid or ambiguous flag: %s"
                                flag))))))
           args))
-        (advice (ad-make-advice
-                 name (memq 'protect flags)
-                 (not (memq 'disable flags))
-                 `(advice lambda ,arglist ,@body)))
+        (advice `(ad-make-advice
+                   ',name ',(memq 'protect flags)
+                   ',(not (memq 'disable flags))
+                   (cons 'advice (lambda ,arglist ,@body))))
         (preactivation (if (memq 'preactivate flags)
                            (ad-preactivate-advice
-                            function advice class position))))
+                            function (eval advice) class position))))
     ;; Now for the things to be done at evaluation time:
     (if (memq 'freeze flags)
        ;; jwz's idea: Freeze the advised definition into a dumpable
@@ -3669,7 +3669,7 @@
        (ad-make-freeze-definition function advice class position)
         ;; the normal case:
         `(progn
-          (ad-add-advice ',function ',advice ',class ',position)
+          (ad-add-advice ',function ,advice ',class ',position)
           ,@(if preactivation
                 `((ad-set-cache
                    ',function






reply via email to

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