From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: era@iki.fi Newsgroups: gmane.emacs.bugs Subject: Re: Bug in emacs Date: 14 Oct 2003 09:05:20 +0300 Organization: People Who Are Not Old Enough For Unix (Honorary Member Emeritus) Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87vfqsl64g.fsf@era.iki.fi> References: <004301c38cd9$2260b1a0$0100a8c0@athlon> <3F8AD296.7010803@yahoo.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1066111583 28373 80.91.224.253 (14 Oct 2003 06:06:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Oct 2003 06:06:23 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 14 08:06:21 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A9IK4-0003ib-01 for ; Tue, 14 Oct 2003 08:06:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A9IK3-0006Mo-Kq for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Oct 2003 02:06:19 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A9IJi-0006FO-5y for bug-gnu-emacs@gnu.org; Tue, 14 Oct 2003 02:05:58 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A9IJ9-0006A6-Fg for bug-gnu-emacs@gnu.org; Tue, 14 Oct 2003 02:05:54 -0400 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A9IJ8-00069t-Rv for bug-gnu-emacs@gnu.org; Tue, 14 Oct 2003 02:05:22 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A9IJ8-0004bV-00 for ; Tue, 14 Oct 2003 08:05:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: bug-gnu-emacs@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A9IJ7-0004bN-00 for ; Tue, 14 Oct 2003 08:05:21 +0200 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A9IJ7-0007MA-00 for ; Tue, 14 Oct 2003 08:05:21 +0200 Original-Lines: 67 Original-X-Complaints-To: usenet@sea.gmane.org User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:5973 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5973 On Mon, 13 Oct 2003 10:28:06 -0600, Kevin Rodgers posted to gmane.emacs.bugs: > era@iki.fi wrote: >> I'm not sure what the bug really is. Perhaps it would be useful to >> get a warning when compiling / evaling something when a macro +is+ >> in effect and the file you are compiling is not pulling it in >> properly? Then at least you get a hint to fix it while you still >> can, while those who do it right will not experience any adverse >> effects. > When the compiler comes across a (function arg ...) form, either the > function is defined or it isn't. If it's defined, either as a function > or a macro, all is well. If it's not defined, the compiler can't know > whether it is a function or a macro and assumes it's a function. A > macro can't be "in effect" if it's file was not loaded "properly". What I'm saying is that macro expansion during compilation could trigger a warning if the macro is not loaded properly by the code which is being compiled. This is a fuzzy idea at best, but I was thinking of something like: 0. Maintain a buffer of per-byte-compilation macros 1. When a new byte compilation starts, flush the buffer of macros. Set a flag to indicate that byte compilation is in progress. (I would kind of assume that this already happens but I haven't checked.) 2. When byte compilation is taking place and a macro is defined, add the macro to the buffer of per-byte-compilation macros with the property "defined during compilation". 3. When byte compilation is taking place and a macro is expanded, check in the buffer, and if the macro is not listed as having been defined during this compilation, throw a warning. 4. When byte compilation finishes, the flag to indicate that byte compilation is taking place will need to be taken down, of course. This obviously requires already-loaded requires etc to be performed anew during byte compilation, or some cunning caching of the buffer which keeps track of when and where a macro was defined (maybe make it global and permanent per session instead of per-compilation?) > The compiler does issue warnings when it encounters an undefined > macro/function: > While compiling the end of the data in file /home/kevinr/emacs/foo.el: > ** the function bar is not known to be defined. So now you'd also get something like While compiling toplevel forms: ** reference to macro `foo' which was not defined during compilation as a warning that the code may not execute correctly on a system where the macro is not somehow automatically loaded before the compiled code will be executed. (As a bonus maybe the `foo' could be clickable so you could look at the macro's documentation and maybe find out where it is defined.) /* era */ -- The email address era the contact information Just for kicks, imagine at iki dot fi is heavily link on my home page at what it's like to get spam filtered. If you 500 pieces of spam for want to reach me, see instead. each wanted message.