[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Auto-Insertion of C/C++ #include-statements upon use of their symbols
From: |
Nordlöw |
Subject: |
Auto-Insertion of C/C++ #include-statements upon use of their symbols |
Date: |
Wed, 17 Sep 2008 08:04:39 -0700 (PDT) |
User-agent: |
G2/1.0 |
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 <string.h>" before
calling memcpy().
In C++ this shall also work for Standard Template Library (STL)
Headers, that is "#include <vector>" is auto-(query-)included when the
user completes the expression "std::vector<int>".
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