Emacs source code navigation features

I am working on a big C ++ project. I have been working with emacs for the past six months. I am trying to configure CEDET to be able to navigate easily, but I found some problems.

1.- Sometimes semantics do not find some characters, and sometimes they don’t ... I don’t know which files are semantic indexing. I tried using EDE (following the instructions in this article http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html ), but I found some problems as well ...

  • I have several versions (releases) of the same project, each of which is in its own folder. How can I tell emacs which project I'm working with?
  • How can I tell ede where to look for my header files? Can I specify only the root directory, and semantics will look for header files in all subdirectories?

2.- I worked with vim + cscope some time ago, and I remember that there was a way to get back to the character stack (Ctrl-t). Is there anything similar in emacs?

PD> Some data to make the question more understandable.

I have several issues of the same project. Each of them has its own root directory. Each project has several modules, each of which is inside a subdirectory. Each module has a header file.

/home/user/ | \Release-001 | | | \makefile | \ Module-001 | | | | | \makefile | | \subdir-001 | | | \header-001.h | | | \header-002.h | | \subdir-002 | | | \header-003.h | \ Module-002 | | | | | \makefile | | \subdir-003 | | | \header-004.h | | | \header-005.h | | \subdir-004 | | | \header-006.h | \Release-002 | | | \makefile | \ Module-001 | | | | | \makefile | | \subdir-001 | | | \header-001.h | | | \header-002.h | | \subdir-002 | | | \header-003.h | \ Module-002 | | | | | \makefile | | \subdir-003 | | | \header-004.h | | | \header-005.h | | \subdir-004 | | | \header-006.h 

This is the EDE configuration that is in my .emacs

 ;; Cedet load commands (add-to-list 'load-path "~/emacs-dir/cedet/cedet") (load-file "~/emacs-dir/cedet/cedet/common/cedet.el") ;; EDE: activating mode. (global-ede-mode t) ;; Projects definition (ede-cpp-root-project "Release-001" :name "Release-001" :file "~/Release-001/makefile" :include-path '("/" ) :system-include-path '("~/exp/include") :spp-table '(("SUSE9" . "") ) ) (ede-cpp-root-project "Release-002" :name "Release-002" :file "~/Release-002/makefile" :include-path '("/" ) :system-include-path '("~/exp/include") :spp-table '(("SUSE9" . "") ) ) 

Just so you know ... I'm working with the console version (-nw) of emacs.

+6
emacs cedet emacs-semantic
source share
2 answers

Your configuration is mostly correct, with the exception of: include-path for your projects.

If the given source file says:

  #include "Module-001/subdir-002/header-003.h" 

then this is normal. If the include indicates:

  #include "subdir-002/header-003.h" 

then your: include-path should have

  :include-path '("/Module-001" ) 

in him.

As for the semantic index, it will index your current file, and it can find it all. Use semantic decoration mode to find out which EDE headers have found for you to determine how correct your configuration is.

It will also index all files in the same directory as the one you are editing, but only in idle mode, so if you do not allow Emacs to idle, it will not be able to bypass it.

You can speed up indexing operations if you use CScope, as Bozhidar suggests. You can then enable CScope support in EDE and in the Semantic database. However, the inclusion of CScope support in Semantic DB is recent, so you will need the CVS version of CEDET. This will make sure that all of this has been indexed.

To jump back, check the help for semantic-mru-bookmark mode. It tracks your progress through your files based on a named location, which is very convenient and always works.

+2
source share

I used Emacs Code Browser in the past when working on C ++ projects, and I found it very satisfactory - in addition to the excellent files and code structure, you get excellent VCS integration (different icons according to the current state of the file in the project). In combination with ECB, I used cscope for Emacs, as you mentioned in vim, you probably want to use it in Emacs too.

Alternatively, if you want a simpler solution, you can look at Emacs Nav . It also supports some fancy stuff and is not dependent on semantics or speed - you will need to use etags / ctags to index your project.

0
source share

All Articles