C/C++ auto complete in emacs using clang in Debian/Ubuntu

I got so accustomed to using Visual Studio 2010 over the course of my internship, that I seriously was missing it while coding in Linux. I knew there were tools available like libclang+vim etc., but they never seemed complete. So finally I sat down and got auto-complete working with emacs in Ubuntu Linux(Note: This should also work in other distributions, but I’ve only tested it on Debian testing and Ubuntu 12.04).

I also got the browsing mode setup which enables me to jump to definitions, see the references of functions etc., A complete setup for browsing source is here.

Here are the steps:

1. Install emacs, emacs-goodies, global, clang, auto-complete

sudo apt-get install emacs emacs-goodies-el global clang auto-complete-el cscope-el

2. Download this emacs conf file and copy it to ~/.emacs

3. Copy the contents of this file into ~/.emacs.d/

4. generate global tags in the rootsource directory by issuing the command

gtags -v

5. Done!

emacs_ftw

Auto complete in emacs using clang
* To search for tags, use M-.
* To search for symbols, use M-]
* To search for function references, use M-[
* To go back to where you were, use M-*

If there are any errors/suggestions, please let me know in the comments. Thanks!

update 11/08/2012: added cscope-el

update 1/30/2014: source code browsing in emacs is much simpler now thanks to global. Check it out: https://github.com/leoliu/ggtags