From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: [drew.adams@oracle.com: RE:weirddefadvicebugwithbyte-compilation] Date: Mon, 12 Dec 2005 20:59:58 -0800 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1134450124 3764 80.91.229.2 (13 Dec 2005 05:02:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 13 Dec 2005 05:02:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 13 06:02:04 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Em2H8-00046J-Ii for ged-emacs-devel@m.gmane.org; Tue, 13 Dec 2005 06:00:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Em2Hf-0003Px-1C for ged-emacs-devel@m.gmane.org; Tue, 13 Dec 2005 00:01:03 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Em2HI-0003Nj-3a for emacs-devel@gnu.org; Tue, 13 Dec 2005 00:00:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Em2HG-0003Mm-Ru for emacs-devel@gnu.org; Tue, 13 Dec 2005 00:00:39 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Em2HG-0003MN-DE for emacs-devel@gnu.org; Tue, 13 Dec 2005 00:00:38 -0500 Original-Received: from [148.87.122.30] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Em2J4-0001RX-Sx for emacs-devel@gnu.org; Tue, 13 Dec 2005 00:02:32 -0500 Original-Received: from rgmsgw300.us.oracle.com (rgmsgw300.us.oracle.com [138.1.186.49]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id jBD501ik000972 for ; Mon, 12 Dec 2005 22:00:01 -0700 Original-Received: from rgmsgw300.us.oracle.com (localhost [127.0.0.1]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id jBD500eN002564 for ; Mon, 12 Dec 2005 22:00:00 -0700 Original-Received: from dradamslap (dhcp-amer-rmdc-csvpn-gw4-141-144-96-242.vpn.oracle.com [141.144.96.242]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id jBD4xxT2002556 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 12 Dec 2005 22:00:00 -0700 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:47610 Archived-At: > Where is the bug? The byte-compiler warning presumably arose > because it compiled a defadvice that referred to variable my-mode. > That variable is not bound in the defadvice body and it might > not be bound at the point in the > file when the defadvice is compiled. Is that a bug? (I thought you actually said elsewhere in this thread that it was a bug, and that you deliberately kept it in the code to reproduce the crash.) No. At one point I mistakenly thought that the byte-compilation was evaling the variable. I was surprised that the quoted unbound variable was evaled (it was the frame creation that tried to check a menu-enable property and evaled the variable). Also, I expected define-minor-mode to somehow DTRT, defining the mode variable first thing when the file was loaded, but I guess it doesn't do that. Users are, I believe, told to turn on a minor mode by using the mode toggle function, not by setting the mode variable. But if you do that in a case like this (as I did, in my .emacs), you can get an unbound-variable error like this. I suspect it is common to use a minor-mode var in a menu-bar menu-enable property, though it is probably uncommon to do so for an existing menu-bar menu (e.g. Search), rather than a menu specific to the mode. > Should people systematically place defadvice last in a file or do > (provide 'x)(require 'x) just to make sure that all variables in a > defadvice body are defined before it is compiled? If you want the byte compiler help you find such typos, then yes, you should try to eliminate gratuitous warnings, to keep the noise level low enough for you to see the real warnings. > I also don't understand, as I mentioned, _why_ the defadvice > in foo.el is byte-compiled - it has no `compile' keyword. I thought this was how defadvice worked, but I might be wrong. In any case, the fact that the byte compiler is run is clear from the backtrace. That it would be run for bar.el, whose defadvice has the keyword `compile', I understand. That it would be run for foo.el, whose defadvice has no `compile', I do not understand. Is that how defadvice works? Can someone clear this up?