Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ETAGS/CTAGS in emacs with C++ Project

Im using emacs and etags to navigate my way round a project, is it possible to get to a header file easily by searching for a function. I have been using VisualStudio and I can view it by clicking goto declaration is there a similar way using etags in emacs?

e.g.

ArchiveDialog::onKeyPress()

search for the declaration of onkeypress that will be in the header file of ArchiveDialog (#include at the top of the source file).

at the moment when im using etags "M-. onKeyPress" will just find the tags in cpp files and not my header files.

Any help would be appreciated Thanks

like image 645
user641902 Avatar asked Jul 19 '11 09:07

user641902


3 Answers

Semantic from CEDET should provide corresponding functionality... Please, look onto this section and into "Semantic User's Guide" for more details...

like image 182
Alex Ott Avatar answered Oct 18 '22 02:10

Alex Ott


Yes, I believe so.

First you should know, there are 2 versions of etags. There is the one that ships with emacs, and the version of etags that comes with Exuberant Ctags.

http://ctags.sourceforge.net/

You want the second version of etags. That version has more options, including an option to tag function prototypes.

I think this option may work for you, although I have not tested it:

--C++-kinds=+p

Once declarations are tagged, both will show up as results when you try to jump to a tag. If you land on the declaration when you want the definition, or vice versa, type "C-u M-." to go to the next match.

I think GNU Global may also let you jump to declarations, although its been a while since I used it. However, Global's C++ parser has some bugs...

like image 39
catphive Avatar answered Oct 18 '22 00:10

catphive


From your description, it sounds like you might have run etags on the source file(s), but didn't specify the #include file(s). Assuming your header (#include) files have '.hh' suffix and are in the same directory as your source, do the following:

cd $project_directory
etags --append *.hh
like image 1
Jim Avatar answered Oct 18 '22 02:10

Jim