[Top][All Lists]

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

Re: CC Mode and GCC/CEDET integration for evaluating macros

From: Oleh Krehel
Subject: Re: CC Mode and GCC/CEDET integration for evaluating macros
Date: Fri, 01 May 2015 20:23:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hello Alan,

Thanks for the response, I'm really glad I asked first before trying to
hack up something on my own.

Alan Mackenzie <address@hidden> writes:

> On Fri, May 01, 2015 at 07:03:05PM +0200, Oleh Krehel wrote:
>> Hi all,
>> I just went through the whole CC Mode manual, just to make sure that I'm
>> not being silly asking for an existing feature.
>> I'd like to be able to evaluate the current symbolic constant at point
>> with "C-x C-e" for C/C++.
> There's nothing like that in CC Mode.  But there is c-macro-expand in
> cmacexp.el which might have something like this, or be easily hackable to
> something like this.

I tried c-macro-expand and it works well for macros defined within the
current file, and even for the standard stuff like __TIMESTAMP__.  But
it doesn't work, for instance for HAVE_PWD_H in editfns.c.  Do you know
if it could work? Is it just a matter of passing some include path to
the preprocessor call?

>> Moreover, I remember when I was using Visual Studio 10 years ago, it
>> had a feature of parsing the macros and graying out #ifdef branches. I
>> found a screenshot of this if it's not clear what I mean:
>> http://stackoverflow.com/questions/11610549/
> There is hide-ifdef-mode in Emacs which does something similar - It makes
> the "non-active" bits of #ifdef branches invisible rather than changing
> their appearance.  Doubtless it would be easy enough to add the "greying
> out" facility as an option.

It appears that `hide-ifdefs' hides them unconditionally.

>> I think it would be really cool to add both these features to CC Mode.
> I'm not sure CC Mode would be the best place for these.  hide-ifdef-mode
> nd c-macro-expand already exist.  I suggest you look at these first.

The functions exist, sure. But for most users they are invisible /
unknown unless they are bound in a keymap. `c-mode-map' is pretty
visible and would be a great way to promote these features.


reply via email to

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