GNU bug report logs - #12610
macros in defadvice are not expanded during byte-compilation

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Le Wang <l26wang@HIDDEN>; dated Tue, 9 Oct 2012 13:04:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 12610 <at> debbugs.gnu.org:


Received: (at 12610) by debbugs.gnu.org; 12 Oct 2012 18:16:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 12 14:16:31 2012
Received: from localhost ([127.0.0.1]:41343 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TMjmg-0004Uu-Oe
	for submit <at> debbugs.gnu.org; Fri, 12 Oct 2012 14:16:31 -0400
Received: from chene.dit.umontreal.ca ([132.204.246.20]:59010)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <monnier@HIDDEN>) id 1TMjme-0004Un-GB
	for 12610 <at> debbugs.gnu.org; Fri, 12 Oct 2012 14:16:28 -0400
Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca
	[132.204.27.242])
	by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q9CIFaq7024370; 
	Fri, 12 Oct 2012 14:15:36 -0400
Received: by faina.iro.umontreal.ca (Postfix, from userid 20848)
	id 70D7AB40A1; Fri, 12 Oct 2012 14:15:36 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#12610: unable to use macro in defadvice
Message-ID: <jwvmwzrk155.fsf-monnier+emacs@HIDDEN>
References: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
	<nwzk3s1m2w.fsf@HIDDEN>
	<jwvy5jbhly9.fsf-monnier+emacs@HIDDEN>
	<tbr4p3o9so.fsf@HIDDEN>
Date: Fri, 12 Oct 2012 14:15:36 -0400
In-Reply-To: <tbr4p3o9so.fsf@HIDDEN> (Glenn Morris's message of
	"Fri, 12 Oct 2012 13:54:47 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-NAI-Spam-Flag: NO
X-NAI-Spam-Level: 
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0.2
X-NAI-Spam-Rules: 2 Rules triggered
	GEN_SPAM_FEATRE=0.2, RV4369=0
X-NAI-Spam-Version: 2.2.0.9309 : core <4369> : streams <836872> : uri <1241793>
X-Spam-Score: -0.3 (/)
X-Debbugs-Envelope-To: 12610
Cc: 12610 <at> debbugs.gnu.org, Le Wang <l26wang@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -0.3 (/)

>> I.e. I think the patch should start more along the lines of the one
>> below (100% guaranteed untested).
[...]
> More importantly, it doesn't work...

That's what I meant by "start".


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.

Message received at 12610 <at> debbugs.gnu.org:


Received: (at 12610) by debbugs.gnu.org; 12 Oct 2012 17:55:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 12 13:55:43 2012
Received: from localhost ([127.0.0.1]:41318 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TMjSY-00040M-HL
	for submit <at> debbugs.gnu.org; Fri, 12 Oct 2012 13:55:43 -0400
Received: from fencepost.gnu.org ([208.118.235.10]:50526 ident=Debian-exim)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TMjSW-00040F-Al
	for 12610 <at> debbugs.gnu.org; Fri, 12 Oct 2012 13:55:41 -0400
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TMjRf-0004Tx-8A; Fri, 12 Oct 2012 13:54:47 -0400
From: Glenn Morris <rgm@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#12610: unable to use macro in defadvice
References: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
	<nwzk3s1m2w.fsf@HIDDEN>
	<jwvy5jbhly9.fsf-monnier+emacs@HIDDEN>
X-Spook: satellite imagery CIDA chameleon man rs9512c BROMURE
X-Ran: dSOk3ig0|o)Qf"ny6Iz8IG%*fw@*r9`6`]tivOh}T@?{UtI.jfa}bT({HQeycRx7LDNfo]
X-Hue: blue
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Fri, 12 Oct 2012 13:54:47 -0400
In-Reply-To: <jwvy5jbhly9.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Fri, 12 Oct 2012 09:35:09 -0400")
Message-ID: <tbr4p3o9so.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 12610
Cc: 12610 <at> debbugs.gnu.org, Le Wang <l26wang@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Stefan Monnier wrote:

> 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.

Sounds right.

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

It causes warnings like:

In toplevel form:
uniquify.el:479:13:Warning: assignment to free variable `ad-return-value'
uniquify.el:487:41:Warning: reference to free variable `ad-return-value'

In end of data:
uniquify.el:511:1:Warning: the function `ad-get-arg' is not known to be
    defined.


More importantly, it doesn't work...

emacs -Q -l uniquify

-> byte-code: Symbol's function definition is void: ad-make-advice


Compiling the initial example from this report gives:

(byte-code "<STUFF>" [ad-add-advice kill-buffer ad-make-advice
show-diff-rephrase-question nil t advice #[nil "<STUFF>" [#:--cl-var--
ad-do-it read-char-choice "(s/k/q)? " append "sSKkQq" nil memql (115 83)
(107 75) (113 81)] 5 "Prompt when a buffer is about to be killed."]
around ad-activate] 8)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.

Message received at 12610 <at> debbugs.gnu.org:


Received: (at 12610) by debbugs.gnu.org; 12 Oct 2012 13:36:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 12 09:36:13 2012
Received: from localhost ([127.0.0.1]:40677 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TMfPQ-0006Mi-9s
	for submit <at> debbugs.gnu.org; Fri, 12 Oct 2012 09:36:13 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:6231)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <monnier@HIDDEN>) id 1TMfPK-0006MB-JZ
	for 12610 <at> debbugs.gnu.org; Fri, 12 Oct 2012 09:36:09 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av8aAG6Zu09FxLQG/2dsb2JhbABEgi6uGoNJgQiCFgEFViMQCw4mEhQYDSSIIboJkEQDozOBWIMF
X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="201255076"
Received: from 69-196-180-6.dsl.teksavvy.com (HELO pastel.home)
	([69.196.180.6])
	by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
	12 Oct 2012 09:35:10 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 0066759519; Fri, 12 Oct 2012 09:35:09 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#12610: unable to use macro in defadvice
Message-ID: <jwvy5jbhly9.fsf-monnier+emacs@HIDDEN>
References: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
	<nwzk3s1m2w.fsf@HIDDEN>
Date: Fri, 12 Oct 2012 09:35:09 -0400
In-Reply-To: <nwzk3s1m2w.fsf@HIDDEN> (Glenn Morris's message of
	"Thu, 11 Oct 2012 22:05:43 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 3.5 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
	has
	identified this incoming email as possible spam. The original message
	has been attached to this so you can view it (if it isn't spam) or
	label similar future email.  If you have any questions, see
	the administrator of that system for details.
	Content preview:  > - `(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. [...] 
	Content analysis details:   (3.5 points, 10.0 required)
	pts rule name              description
	---- ----------------------
	--------------------------------------------------
	-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,
	low trust [206.248.154.182 listed in list.dnswl.org]
	0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail)
	2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
	0.8 BAYES_50               BODY: Bayes spam probability is 40 to 60%
	[score: 0.5000]
X-Debbugs-Envelope-To: 12610
Cc: 12610 <at> debbugs.gnu.org, Le Wang <l26wang@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: 3.5 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has
 identified this incoming email as possible spam.  The original message
 has been attached to this so you can view it (if it isn't spam) or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  > - `(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. [...] 
 
 Content analysis details:   (3.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at http://www.dnswl.org/, low
                             trust
                             [206.248.154.182 listed in list.dnswl.org]
  0.7 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.8 BAYES_50               BODY: Bayes spam probability is 40 to 60%
                             [score: 0.4999]

> -		  `(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





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.
Changed bug title to 'macros in defadvice are not expanded during byte-compilation' from 'unable to use macro in defadvice' Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 12610 <at> debbugs.gnu.org:


Received: (at 12610) by debbugs.gnu.org; 12 Oct 2012 03:47:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 11 23:47:07 2012
Received: from localhost ([127.0.0.1]:40141 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TMWDK-0007AJ-Lz
	for submit <at> debbugs.gnu.org; Thu, 11 Oct 2012 23:47:07 -0400
Received: from fencepost.gnu.org ([208.118.235.10]:60506 ident=Debian-exim)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TMWDH-0007AA-HP
	for 12610 <at> debbugs.gnu.org; Thu, 11 Oct 2012 23:47:04 -0400
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TMWCU-0004EJ-ES; Thu, 11 Oct 2012 23:46:14 -0400
From: Glenn Morris <rgm@HIDDEN>
To: Le Wang <l26wang@HIDDEN>
Subject: Re: bug#12610: unable to use macro in defadvice
References: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
	<nwzk3s1m2w.fsf@HIDDEN>
X-Spook: Venezuela Noriega Panama 64 Vauxhall Cross Aldergrove
X-Ran: "0Jx~9;"?=v2OfZvwuO*+gJ(>)-yI>3`<MF9xui-D?O.x|`84f=+"Y~sztLDNR},Olr#x_
X-Hue: cyan
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Thu, 11 Oct 2012 23:46:14 -0400
In-Reply-To: <nwzk3s1m2w.fsf@HIDDEN> (Glenn Morris's message of
	"Thu, 11 Oct 2012 22:05:43 -0400")
Message-ID: <14d30oe4jd.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 12610
Cc: 12610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.3 (------)


Actually I guess it would be better for the byte-compiler to do the
expansion.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.

Message received at 12610 <at> debbugs.gnu.org:


Received: (at 12610) by debbugs.gnu.org; 12 Oct 2012 02:06:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 11 22:06:34 2012
Received: from localhost ([127.0.0.1]:40110 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TMUe2-0004sv-3A
	for submit <at> debbugs.gnu.org; Thu, 11 Oct 2012 22:06:34 -0400
Received: from fencepost.gnu.org ([208.118.235.10]:59059 ident=Debian-exim)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <rgm@HIDDEN>) id 1TMUe0-0004so-74
	for 12610 <at> debbugs.gnu.org; Thu, 11 Oct 2012 22:06:32 -0400
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1TMUdD-0001p1-RO; Thu, 11 Oct 2012 22:05:44 -0400
From: Glenn Morris <rgm@HIDDEN>
To: Le Wang <l26wang@HIDDEN>
Subject: Re: bug#12610: unable to use macro in defadvice
References: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
X-Spook: BLU-114/B bank enforcers national information
X-Ran: g[LJ=YqmUu[~zZ8Hm!f(GW-WGhAT2osI=|t)fU&U[Q(:5bBkUcnfLJI~?#V_FsNHJNwoQv
X-Hue: black
X-Attribution: GM
Date: Thu, 11 Oct 2012 22:05:43 -0400
In-Reply-To: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
	(Le Wang's message of "Tue, 9 Oct 2012 21:02:58 +0800")
Message-ID: <nwzk3s1m2w.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 12610
Cc: 12610 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.3 (------)


Interesting. Advice does not macroexpand the advice definition.
I guess it should?

*** lisp/emacs-lisp/advice.el	2012-09-14 13:44:31 +0000
--- lisp/emacs-lisp/advice.el	2012-10-12 02:02:39 +0000
***************
*** 3658,3664 ****
  	 (advice (ad-make-advice
  		  name (memq 'protect flags)
  		  (not (memq 'disable flags))
! 		  `(advice lambda ,arglist ,@body)))
  	 (preactivation (if (memq 'preactivate flags)
  			    (ad-preactivate-advice
  			     function advice class position))))
--- 3658,3664 ----
  	 (advice (ad-make-advice
  		  name (memq 'protect flags)
  		  (not (memq 'disable flags))
! 		  `(advice lambda ,arglist ,@(macroexpand-all body))))
  	 (preactivation (if (memq 'preactivate flags)
  			    (ad-preactivate-advice
  			     function advice class position))))





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Oct 2012 13:03:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 09 09:03:59 2012
Received: from localhost ([127.0.0.1]:34897 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TLZTa-0002oW-P2
	for submit <at> debbugs.gnu.org; Tue, 09 Oct 2012 09:03:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41118)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <l26wang@HIDDEN>) id 1TLZTY-0002oJ-B3
	for submit <at> debbugs.gnu.org; Tue, 09 Oct 2012 09:03:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <l26wang@HIDDEN>) id 1TLZSs-0003g5-1D
	for submit <at> debbugs.gnu.org; Tue, 09 Oct 2012 09:03:17 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:35595)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <l26wang@HIDDEN>) id 1TLZSr-0003fy-Tu
	for submit <at> debbugs.gnu.org; Tue, 09 Oct 2012 09:03:13 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42123)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <l26wang@HIDDEN>) id 1TLZSm-0001Ue-OI
	for bug-gnu-emacs@HIDDEN; Tue, 09 Oct 2012 09:03:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <l26wang@HIDDEN>) id 1TLZSd-0003bl-67
	for bug-gnu-emacs@HIDDEN; Tue, 09 Oct 2012 09:03:08 -0400
Received: from mail-qc0-f169.google.com ([209.85.216.169]:58590)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <l26wang@HIDDEN>) id 1TLZSd-0003bd-2F
	for bug-gnu-emacs@HIDDEN; Tue, 09 Oct 2012 09:02:59 -0400
Received: by mail-qc0-f169.google.com with SMTP id t2so5349376qcq.0
	for <bug-gnu-emacs@HIDDEN>; Tue, 09 Oct 2012 06:02:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=heGdg1yccVnQtma8MDpS96CMo5gb8yOpQXpTsLZz5pE=;
	b=kezLGpHM6O0k0Ahmkk7ZzV7Vg8+pfCZiyYDWQy3XLoJ/xsuapdL879UvfX7cRZf0h3
	BOgunjjvhXm/7+bYJRHPTmcjQU/ffUlKYfgTEgti8D0vLsxXfhQEydbmCIWu9lXjW59E
	ihycnqxaky1AKpBHtY8cdaF/MW17vb9+4g/9bD56i0RtALVH/OkqdTSLgQJAByhiXtoU
	//IjKqLSkJ9B1II7qvlwwZfdTTnwI6d4wuuiHJ/Yy67KctNyULux54dkv3At1dXsti0G
	TW7+2iX1q30vj2KiT5dpLIb85Z3ZhAsmm0Z6A15yBIgL2P/RK+Fu2almI4MXUIEBV2or
	yCKA==
MIME-Version: 1.0
Received: by 10.224.180.16 with SMTP id bs16mr34711367qab.58.1349787778146;
	Tue, 09 Oct 2012 06:02:58 -0700 (PDT)
Received: by 10.49.50.7 with HTTP; Tue, 9 Oct 2012 06:02:58 -0700 (PDT)
Date: Tue, 9 Oct 2012 21:02:58 +0800
Message-ID: <CAM=K+iq-7ijbLg+-mtnKShVhQQFuPORDc5nbUEsqZidgtNNp=A@HIDDEN>
Subject: unable to use macro in defadvice
From: Le Wang <l26wang@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.118.235.17
X-Spam-Score: -3.4 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.4 (---)

Relevant stackoverflow question:
http://stackoverflow.com/questions/12767353/using-macros-in-defadvice

I have this simplified macro.

(defadvice kill-buffer (around show-diff-rephrase-question activate compile)
  "Prompt when a buffer is about to be killed."
  (case (read-char-choice
         "(s/k/q)? "
         (append "sSKkQq" nil))
    ((?s ?S)
     ad-do-it)
    ((?k ?K)
     ad-do-it)
    ((?q ?Q) nil))
  ad-do-it)

If I compile the file and load it, then I get "Invalid function: (115 83)"

It works if I evaluate it.

-- 
Le




Acknowledgement sent to Le Wang <l26wang@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#12610; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.