emacs中有没有办法使用正则来找到C文件里所有的函数定义

elpy可以使用下面这句找出一个python文件中所有的函数定义。

(occur "^ *\\(def\\|class\\) ")

有没有好办法同样occur出来一个C文件里面所有的函数?

试试 helm-semantic-or-imenu ?

谢谢,这个我之前用过。我只是在使用python的时候发现occur这个功能挺好用的。想对应弄到C中。

imenu 应该就是这个功能的……还是说 occur 除了显示所有 class 并可以跳转以外还有其他用处?

反正我用 counsel-imenu-goto 感觉体验很好。 python里

c++ 里

感觉用正则来匹配c中的函数定义有点麻烦

是的。其实我的问题应该改一下。如何使用emacs中的正则来匹配C函数。

感觉用正则很难。

你需要 ECB

额,我觉得使用ecb和cedet搞C\C++,正常点

谢谢。我试了ecb是可以找出来的。但是我觉得它有点 “大” 了。属于重量级的。

谢谢。这两个东西我都没有使用。可能以后实在有需求的时候再试试吧。

楼上几位提到的 imenu 以及变种,都可以列出 c 文件里的函数并跳转,所以你问题的重点在哪里?

重点你可以理解为是 正则

你可以看看这个,好像是用的正则,虽然它是跳定义也许会简单一点……但说不定呢?

#How it works Dumb Jump uses The Silver Searcher ag, ripgrep rg, or grep to find potential definitions of a function or variable under point. It uses a set of regular expressions based on the file extension, or major-mode, of the current buffer. The matches are run through a shared set of heuristic methods to find the best candidate to jump to. If it can’t decide it will present the user with a list in a pop-menu.

谢谢。我准备研究下。不过现在用不起来。'-non-nil’函数找不到。我在它的github上提了一个 issue