简体   繁体   English

在Emacs中进行C开发时如何跳转到功能?

[英]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程序,它可以理解CC++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.

相关问题 C 函数指针:我可以跳转到堆内存汇编代码吗? - C function pointer: Can I jump to heap memory assembler code? MASM和C跳转功能 - MASM and C jump to function 使用C做GUI时如何避免使用控制台? - How can I avoid the Console while doing GUI with C? 如何使用Visual Studio 2010进行C开发? - How can I use Visual Studio 2010 for C development? 我如何跳到上半部分内核 - how can I jump to the higher half kernel 在 C 中,当调用 function 时,如何确定 argv[1] 的长度? - In C, how can I determine the length of argv[1], when calling a function? 如何跳转到C / C ++函数声明而不是它的定义? - How to jump to a C/C++ function declaration instead of its definition? 我究竟做错了什么? 如何将读取功能中分配的内存传递给显示功能? - What am i doing wrong? How can i pass the memory allocated in read function to disp function? 如何让Emacs正确缩进C99复合文字? - How can I make Emacs properly indent C99 compound literals? 当我进行正整数检查时无法避免 C 中的 nullptr - Can't avoid the nullptr in C when I am doing a positive integer check
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM