简体   繁体   English

像Sublime CMD + R一样弹出Emacs列表函数定义

[英]Emacs list function definitions popup like Sublime CMD + R

In Sublime Text (Mac OS X), you can do CMD + R shortcut to list function definitions in a popup. 在Sublime Text(Mac OS X)中,您可以执行CMD + R快捷方式以在弹出窗口中列出功能定义。 When you type function names, it does fuzzy matching to show matches. 键入函数名称时,它将执行模糊匹配以显示匹配项。 Press enter and go to the definition. 按Enter键并转到定义。 I find it very handy. 我觉得很方便。

In Emacs, is there something like that? 在Emacs中,是否有类似的东西?

I'm using elpy for writing Python and I found elpy-occur-definitions (Cc Co) which can show function definitions in a different buffer. 我使用elpy编写Python,发现elpy-occur-definitions (Cc Co)可以在不同的缓冲区中显示函数定义。 Close. 关。 But not exactly what I want. 但不完全是我想要的。

Thanks! 谢谢!

Thanks to @jenesaisquoi's comment, I found helm-imenu-anywhere which does exactly what I want. 感谢@jenesaisquoi的评论,我发现helm-imenu-anywhere完全符合我的要求。

I override this key-binding Mr (since I don't use the navigation function that often) which is also very close to Cmd-R. 我重写了此键绑定Mr (因为我不经常使用导航功能),这也非常接近Cmd-R。

(global-set-key (kbd "M-r") 'helm-imenu-anywhere)

UPDATE: 更新:

If you are on Mac OS X and want to use the same CMD + R to do this, you ca bind the key to sr instead: 如果您使用的是Mac OS X,并且想使用相同的CMD + R来执行此操作,则可以将密钥绑定到sr

(global-set-key (kbd "s-r") 'helm-imenu-anywhere)

UPDATE 2: 更新2:

I found that, to list functions in current buffer (versus out of all files), the best trick is helm-semantic-or-imenu . 我发现,要列出当前缓冲区中的函数(而不是所有文件中的函数),最好的技巧是helm-semantic-or-imenu So my ultimate setup is 所以我的最终设置是

(global-set-key (kbd "s-r") 'helm-semantic-or-imenu)
(global-set-key (kbd "s-o") 'helm-imenu-anywhere)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM