Auto-Insertion of C/C++ #include-statements upon use of their symbols
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

 Up
Auto-Insertion of C/C++ #include-statements upon use of their symbols         

Group: gnu.emacs.help · Group Profile
Author: Nordlöw
Date: Sep 17, 2008 08:04

I am currently writing some logic for automatically looking up a
required header file when the programmer completes the use of a symbol
defined in this header file. This to relieve especially C/C++
programmers from the cumbersome process of doing for example "man
memcpy" to figure out that we need to "include " before
calling memcpy().

In C++ this shall also work for Standard Template Library (STL)
Headers, that is "#include " is auto-(query-)included when the
user completes the expression "std::vector".

The logic for these lookups and insertions already exists. What now
remains is the logic for sensing when this is needed.

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?

If any one is interested in using this add-ons I will gladly send it
to you.

Many Thanks in advance,
Nordlöw
5 Comments
diggit! del.icio.us! reddit!