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

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

Re: file/line info for macro expansion


From: Steven W. Orr
Subject: Re: file/line info for macro expansion
Date: Wed, 05 Jan 2011 09:50:19 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

On 1/5/2011 1:11 AM, Stefan Monnier wrote:
However, both `find-function' and `find-variable' seem to know file
and line number where a function/variable has been defined.

Emacs knows the file name (in most cases, at least), thanks to
load-history.  But it doesn't know the line number.  Instead,
find-function will look for the definition with a regular expression.


         Stefan

I find this question to be interesting. I have written a lot of python and C code where I needed to enable debug modes, but I also had a requirement for the debug code to not place any overhead on the code when debug mode was not enabled.

I solved this problem by elevating the code to a higher level. In my case, I found a preprocessor called cog (which happens to be written in python, though any preprocessor would do). Then instead of writing my .py files, I write .cog.py files which get run through a Makefile to produce the resulting .py files. The preprocessor expands the macros (or not) as specified on the make command line, and the result contains exactly what I want it to have.

In the case of .el files, I understand that the current line number is not terribly easily accessible, and I understand why (for the most part). Python has less of a problem in this regard. So, it would be easy to embed (something like) cog macros in a .cog.el file and after the .el file was produced, the resulting file would contain actual line numbers in the code.

And, if you are not trying to debug a problem, then the el files that you would be running would not (have to) contain any expanded macros.

Here's the link for the cog home page, but frankly, I only mention this because I found it, it was easy to use and it beats using m4. If someone likes some other system better, that's just peachy.

The big thing is if the idea of a preprocessor has any appeal at all, or if this feels like it's more trouble than it's worth.

http://nedbatchelder.com/code/cog/

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



reply via email to

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