Emacs source code navigation features
Asked Answered
I

2

6

I am working on a large c++ project. I am working with emacs for the last six months. I have try to configure CEDET so as to be able to navigate easily but i have found some problems.

1.- Sometimes semantic does not find some symbols and sometimes he don't ... i do not know clearly which files is semantic indexing. I have tried to use EDE (following the instructions in this paper http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html), but i have found some problems also...

  • I have multiple version ( Releases) of the same project, each one in its own folder. How can i tell emacs which project i am working with?
  • How can i tell ede where to look for my header files? Can I specify just a root directory and semantic will search for header files in all the subdirectories?

2.- I was working with vim+cscope some time ago and i remember there was a way to navigate back in the stack of symbols (Ctrl-t). Is there anything like this in emacs?

P.D.> Some data to make the question more clear.

I have multiple releases of the same project. Each one has its own root directory. Each project has multiple modules each one inside a subdirectory. There are headers file in each module.

/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 configuration about EDE i have 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 to let you know ... I am working with the console version ( -nw) of emacs.

Immuno answered 19/8, 2010 at 8:29 Comment(2)
What problems did you encounter with EDE?Foulard
I have edited the question to add some new information. Thanks for your interest.Immuno
E
2

Your configuration is basically correct, except for the :include-path for your projects.

If a given source file says:

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

then it is ok. If the include says:

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

then your :include-path should have

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

in it.

As for which things does semantic index, it will index your current file, and all includes it can find. Use the semantic-decoration mode to see which headers EDE has found for you to determine if your configuration is accurate.

It will also index all files in the same directory as the one you are editing, but only in idle time, so if you don't let Emacs be idle, it won't get around to it.

You can speed the indexing operations up if you use CScope as Bozhidar suggests. You can then enable the CScope support in both EDE and the Semantic database. The inclusion of CScope support in Semantic DB is recent, however, so you would need the CVS version of CEDET. That would make sure the whole thing was indexed.

To navigate backward, investigate the help for semantic-mru-bookmark-mode. This tracks your progress through your files on a named location basis that is quite handy and always works.

Epicycloid answered 19/8, 2010 at 22:18 Comment(2)
Thanks for your answer. The problem is that the header files are spread all over the project. Each module has sub folders and the headers are inside this sub folders, so specify all the paths where headers are would be a hell. - Is there any way to tell Semmantic to look for headers in all the sub directories down a root path? - Reading EDE documentation i have found that "Instead of specifying paths as lists, you can also provide function, that will perform a search for include files in your project." Unfortunately i do not know elisp. Any place where i can find an example? Thanks!Immuno
The purpose of the include path is to make path lookup faster by focusing it down. If there is no benefit to that, then your best bet is to use CScope. Once CScope is enabled as an EDE locate feature (See the variable ede-locate-setup-options) then it is sort of like having everything as an include path for all files. There are probably some caveats but I haven't tried this trick myself to know for sure.Epicycloid
G
0

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

Alternatively if you want a simpler solution you might have a look at Emacs Nav. It supports some fancy stuff as well and has no dependency to semantic and speedbar - you'll only have to use etags/ctags to index your project.

Gyno answered 19/8, 2010 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.