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: Chetan
Subject: Re: Auto-Insertion of C/C++ #include-statements upon use of their symbols
Date: Wed, 17 Sep 2008 11:39:13 -0700
User-agent: Emacs Gnus

David <de_bb@arcor.de> writes:

> 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?
>
> Quick&Dirty "solution": use font-lock information, i.e. look at the face
> of the current symbol.
>
> 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?
>
> -David
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.

Chetan


reply via email to

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