[英]How can I jump to function when doing C development in Emacs?
I am doing C development in Emacs. 我在Emacs做C开发。 If I have a source file open with multiple functions and "the marker" is at a function call eg int n = get_number(arg);
如果我有一个打开了多个函数的源文件,并且“标记”处于函数调用,例如int n = get_number(arg);
is there any way I can "jump to" the implementation of that function? 有什么方法可以“跳转”到该功能的实现? eg to int get_number(int *arg) { ... }
例如, int get_number(int *arg) { ... }
I have done some Java development in Eclipse and is missing this functionallity, because I'm not that used to Emacs but I would like to learn. 我在Eclipse中做了一些Java开发并且缺少这个功能,因为我不习惯Emacs,但我想学习。
You have to create a tag file. 您必须创建标记文件。
Under Unix, you have the etags
program that understands the syntax of C
, C++
, Java
... and that create a tag
file that can be used by Emacs. 在Unix下,你有etags
程序,它可以理解C
, C++
, Java
的语法......并创建一个可供Emacs使用的tag
文件。
This rather old page (2004) provides more information. 这个相当古老的页面 (2004)提供了更多信息。
To jump to a function use M-. 要跳转到某个功能,请使用M-。 (that's Meta-Period) and type the name of the function. (那是Meta-Period)并输入函数的名称。 If you simply press enter Emacs will jump to the function declaration that matches the word under the cursor. 如果只需按Enter键,Emacs将跳转到与光标下的单词匹配的函数声明。
There are several "tags" systems which allows that (there is one bundled with emacs, there is GNU global which isn't bundled with emacs but integrate well with it and has some advantages). 有几个“标签”系统允许(有一个捆绑了emacs,有GNU全球,没有与emacs捆绑,但与它很好地集成,并具有一些优势)。 Compared with Eclipse, you'll need to build the tags file. 与Eclipse相比,您需要构建标记文件。
Then there is semantic/EDE which is now bundled with emacs which should provide a solution without needing to build a database explicitly. 然后是语义/ EDE,现在捆绑了emacs,它应该提供一个解决方案,而不需要显式地构建数据库。 I've not tried to use it recently. 我最近没试过用它。 When I did, it has performance problem and I found the set up was painful. 当我这样做时,它有性能问题,我发现设置很痛苦。 (Both possibly due to the fact that I'm working on a big -- several 10's millions lines -- and old -- some things date back to the mid 80's -- project without the possibility of reorganizing it). (这可能是因为我正在努力开发一个大型的 - 几百万行 - 而且旧的 - 有些东西可以追溯到80年代中期 - 项目没有重组的可能性)。
I think semantic-mode should do you the same result. 我认为语义模式应该会给你相同的结果。 Although I haven't tried to jump to another file, but in one file it's very excellent. 虽然我没有尝试跳转到另一个文件,但在一个文件中它非常优秀。 Go to a variable, issue keystroke Cc , j , it will jump to the definition of the variable. 转到一个变量,发出击键Cc , j ,它会跳转到变量的定义。 Go back to previous line using Cu C-space . 使用Cu C-space返回上一行。 To display reference to the symbol, use keystroke Cc , g 要显示符号的引用,请使用按键Cc , g
It really helps me. 这对我很有帮助。 I haven't tried it to jump to another file, because my current project is a modified Java program, where we are using preprocessor (a non standard java process). 我没有尝试过它跳转到另一个文件,因为我当前的项目是一个修改过的Java程序,我们使用预处理程序(非标准的java进程)。 So I think that is where the problem lies. 所以我认为这就是问题所在。
Anyone success with semantic-mode??? 任何语义模式的成功???
thanks 谢谢
我真的很喜欢cscope,但etags也可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.