From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Glenn Morris <rgm@gnu.org>
Cc: 12610@debbugs.gnu.org, Le Wang <l26wang@gmail.com>
Subject: bug#12610: unable to use macro in defadvice
Date: Fri, 12 Oct 2012 09:35:09 -0400 [thread overview]
Message-ID: <jwvy5jbhly9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <nwzk3s1m2w.fsf@fencepost.gnu.org> (Glenn Morris's message of "Thu, 11 Oct 2012 22:05:43 -0400")
> - `(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
next prev parent reply other threads:[~2012-10-12 13:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 13:02 bug#12610: unable to use macro in defadvice Le Wang
2012-10-12 2:05 ` Glenn Morris
2012-10-12 3:46 ` Glenn Morris
2012-10-12 13:35 ` Stefan Monnier [this message]
2012-10-12 17:54 ` Glenn Morris
2012-10-12 18:15 ` Stefan Monnier
2020-09-13 16:43 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvy5jbhly9.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=12610@debbugs.gnu.org \
--cc=l26wang@gmail.com \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.