简体   繁体   English

如何确定emacs完成源的优先级?

[英]How to prioritize emacs completion sources?

When auto completing inside a buffer, I've found that nearby words are not at that top of the list but I want them to be. 当在缓冲区内自动完成时,我发现附近的单词不在列表的顶部,但我想要它们。

I'm using auto-complete right now, but I am open to using something else that can do comprehensive completion (combining many sources, such as words in buffer, project, programming language completion, etc.) and automatically displays candidates as I type. 我现在正在使用自动完成,但我愿意使用其他可以全面完成的东西(结合许多来源,例如缓冲区中的单词,项目,编程语言完成等)并在我输入时自动显示候选。

I've read over documentation on auto-complete and company mode. 我已阅读有关自动完成和公司模式的文档。 The only thing I can find is turning sources on and off, but nothing about prioritizing them, which is what I want to do. 我唯一能找到的就是打开和关闭来源,但没有关于优先排序的事情,这就是我想做的事情。 I can imagine several ways to accomplish this, like altering these packages, or writing code to combine and prioritize sources, but it just seems like someone must have done this already. 我可以想象几种方法来实现这一点,比如改变这些包,或编写代码来组合和优先考虑源代码,但似乎有人必须已经完成了这一点。

Edit: I've tracked down part of the problem to the autocomplete source which is supposed to do completion for words in the buffer (ac-source-words-in-same-mode-buffers) not prioritizing words nearby, but the original question still stands. 编辑:我已经将部分问题追溯到自动完成源,该源应该完成缓冲区中的单词(ac-source-words-in-same-mode-buffers),而不是优先处理附近的单词,但原始问题仍然站着。

Emacs's built-in dabbrev-expand function is worth experimenting with. Emacs的内置dabbrev-expand功能值得尝试。 The function is automatically bound to M-/ in standard modes. 该功能在标准模式下自动绑定到M- /。

auto-complete prioritizes by previously completed completions and then by shortest completion. 通过先前完成的完成然后通过最短完成来自动完成优先级。 It could be altered in the auto-complete source, or a function combining sources and prioritizing them could be written. 它可以在自动完成源中进行更改,也可以编写组合源并对其进行优先级排序的函数。

Hippie completion is closer to solving the problem; 嬉皮完成更接近于解决问题; it prioritizes sources by their order in a list, and it has a completion source of words nearby in the form of "visible words." 它按照列表中的顺序对来源进行优先排序,并且在“可见单词”的形式附近有单词的完成源。 It does not have an automatic completion UI, but it could be hooked into auto-complete. 它没有自动完成UI,但它可以挂钩到自动完成。

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

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