简体   繁体   English

使emacs自动完成Ruby方法

[英]Make emacs autocomplete Ruby methods

Is there a way to make emacs pull autocompletions of ruby methods the way Eclipse and NetBeans do? 有没有办法让emacs按照Eclipse和NetBeans的方式提取ruby方法的自动完成功能? That is if I type File. 那就是我输入文件。 and press CTRL-space in Eclipse I will get a list of File methods. 并按下Eclipse中的CTRL-space我将获得一个File方法列表。 Same with variables. 与变量相同。 I have installed autocomplete plugin, ruby-mode, rinari and cedet, but so far it will complete local variable and method names, but will not native ones. 我已经安装了自动完成插件,ruby-mode,rinari和cedet,但到目前为止它将完成局部变量和方法名称,但不会是原生的。

I think you need something like RSense . 我认为你需要像RSense这样的东西 You might also like the more general auto complete mode . 您可能也喜欢更一般的自动完成模式

I'm not familiar with ruby, but if by "native methods" you mean stuff in some system library, there are a couple options for extending CEDET to do the work. 我不熟悉ruby,但如果用“本地方法”表示某些系统库中的东西,那么有两种选择可以扩展CEDET来完成工作。

If there are ruby files somewhere that have all that code in them, and if ruby supports some sort of "include" or "import" statement, then you need to add that location to the include path for ruby. 如果某些地方有ruby文件,其中包含所有代码,并且如果ruby支持某种“include”或“import”语句,那么您需要将该位置添加到ruby的包含路径中。 This probably requires a change the the ruby source code to add a new system include path. 这可能需要更改ruby源代码以添加新的系统包含路径。 You can see examples in semantic-c.el. 您可以在semantic-c.el中查看示例。 You may also need to override the function semantic-tag-include-filename to convert the include into a findable filename. 您可能还需要覆盖函数semantic-tag-include-filename以将include转换为可查找的文件名。

If there are no includes, and there is just some ruby interpreter that knows all this stuff, then you will instead need to code up a full ruby "omniscient" database, similar to semanticdb-el.el. 如果没有包含,并且只有一些ruby解释器知道所有这些东西,那么你将需要编写一个完整的ruby“omniscient”数据库,类似于semanticdb-el.el。 It will need a way to query ruby for various things and return them as answers. 它需要一种方法来查询ruby中的各种事物并将它们作为答案返回。

Any such enhancements would be welcome back in the ruby support in CEDET's contrib area. 任何此类增强都将受到CEDET贡献区域的红宝石支持的欢迎。

Ruby is an interpreted language, making it difficult to do certain things, such as autocompletion. Ruby是一种解释型语言,因此很难做某些事情,例如自动完成。 How would you know what the object type is, if it's not defined? 你怎么知道对象类型是什么,如果没有定义的话? Therefore, premade solutions are limited or nonexistent. 因此,预制解决方案是有限的或不存在的。 Even the autocompletion in Netbean/Eclipse will only work on class methods (if I'm not mistaken). 甚至Netbean / Eclipse中的自动完成也只适用于类方法(如果我没弄错的话)。

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

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