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

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

Re: Auto-Insertion of C/C++ #include-statements upon use of their symbol


From: David
Subject: Re: Auto-Insertion of C/C++ #include-statements upon use of their symbols
Date: Wed, 17 Sep 2008 23:54:27 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.3 (gnu/linux)

>> Nordlöw <per.nordlow@gmail.com> writes:
>>> My suggestion is to make Emacs call a function each time a character
>>> is inserted into buffer and then check if we are currently standing
>>> behind such a use pattern. I believe looking-back() is usable here.
>>
>>> We also need to check that the cursor is *NOT* currently standing
>>> inside a comment or string; How do I query such a context?

> David <de_bb@arcor.de> writes:
>> Better solution: Since you are using semantic anyway, you could override
>> `semantic-ctxt-current-symbol' for C/C++, so that no symbol is returned
>> when the point is in a comment or string. Eric can surely say if this
>> would be reasonable to do.
>>
>> I'm not sure all of this will be fast enough for calling it in something
>> like 'post-command-hook, though. Maybe this should just be an extra
>> command, which inserts the correct header for the current symbol, if
>> necessary?

Chetan <Chet.xspam@xspam.sbcglobal.net> writes:
> This looks like something that abbrev-mode, expand and other template
> packages do already. I am not sure what you are trying to do and how it
> is differs from any of those.

He wants to automatically add proper #include statements as soon as you
use external functions. In practice, this would mean you wouldn't have
to write any #include statements at all, since they would be
automatically added as you write your code (and also removed again when
not needed anymore, although this would be more difficult to do). By
using CEDET's templating system SRecode, this could even be made
language independent. I don't think the usual templating systems can do
that.

-David





reply via email to

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