views:

170

answers:

2

Suppose I am editing a buffer containing C code.

I have started semantic with semantic-load-enable-code-helpers .

I have point placed on the name of a function . If I then invoke senator-jump I can jump to the place where that fn is first declared, in that module. If there is an extern declaration in that module, then it goes to that extern statement. Sometimes? Sometimes it doesn't work, though.

There is also semantic-ia-fast-jump, which jumps to the first declaration, also. I'm not sure how this fn differs from senator-jump. This one actually works all the time, though, for functions defined in the local buffer.

What if it the function I want to jump to, is an extern? Is it possible to use senator to jump to the definition of the fn, if that definition resides in a separate module? Isn't EDE supposed to do something like this?

Thanks.

+1  A: 

I haven't used senator but doesn't etags work for you? I create a tags table of all .c. and .h files using

find . -name \*.c -o -name \*.h | xargs etags

and then use find-tag (bound by default to M-.) and jump to the appropriate definition. pop-tag-mark (bound by default to M-*) can be used to return to where you came from.

It works fine for me but I use it mainly while browsing large project codebases rather than which editing C.

Noufal Ibrahim
ya, I know it's possible in etags. But I've been trying to use semantic/cedet lately. Some of the capability seems really nice. Much of it is still pretty obscure, to me.
Cheeso
+2  A: 

Look to the semantic-ia-fast-jump function, defined in semantic-ia. For C & C++ it's also good idea to generate database with gtags from GNU Global - CEDET has support for it.

P.S. I just checked - it jumped from my source to declaration of std::string in /usr/include/....

Alex Ott
Thanks Alex - it jumped after you generated the database, right? You need the gtags database first, right?
Cheeso
ok, this is odd. I used the `semantic-ia-fast-jump`, and for *some* functions, it finds the fn definition in an external module. For others, it does not. I haven't run etags or gtags. you eevr see anything like that? Not that you asked, but... seems to me CEDET is an ambitious project, but it strikes me as very unpolished. There's completion and navigation in semantic, there's completion and navigation in senator. They work similarly, but not the same, and neither seems to be consistent.
Cheeso
hmm - does the external module maybe have to be open within the emacs session, for it to find the symbol? Maybe you don't know this and I should just ask on the semantic mailing list. I sent a few questions there, got nothing back.
Cheeso
if gtags/ctags database exists, then CEDET uses it. If not, then it tries to parse all corresponding includes and look into them. All parsed data are stored in semanticdb, and later used when running all CEDET commands.It seems, that not all header files were parsed in your case - may be was something wrong with include paths, or something like
Alex Ott
yah, well this is C code, so. . . there is not necessarily a 1:1 correspondence between H and C module. Also no need to have a .h for each .c. So, how does Semantic figure out what c modules to parse? I didn't see this in the documentation. I should probably pursue this somewhere else, eh?
Cheeso
the better way is to help CEDET with tags database. You can also look to EDE's simple projects
Alex Ott