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 18:18:37 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2.90 (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?

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





reply via email to

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