我可以在任何地方使用 ido-completing-read 而不是 Complete-read 吗?
我是 ido-mode
的忠实粉丝,以至于我想将它用于 describe-function
或 find-tag 等等,而不必编写类似“我可以在 Emacs 中搜索标签时获得 ido-mode-style 补全吗?”之类的内容。 为每一个。
都
(defalias completing-read ido-completing-read)
和
(setf 'completing-read 'ido-completing-read)
不起作用,至少部分是因为 ido-completing-read 在其主体中调用了 completing-read,因此任何简单的重新定义都会导致无限递归。
从理论上讲,这应该是可能的,因为 ido-completing-read
的文档字符串的第一行是“Ido replacement for thebuilt-in completing-read
”。 我环顾四周,似乎找不到其他人尝试过或成功做到这一点。
我意识到 Icicles 可能提供了类似的东西,无论如何我最终可能会这样做,但它比我现在愿意承担的风险更大一些。
谢谢你的帮助。
I'm a big fan of ido-mode
, so much so that I would like to use it for things like describe-function
or find-tag
and so on, without having to write something like in "Can I get ido-mode-style completion for searching tags in Emacs?" for each one.
Both
(defalias completing-read ido-completing-read)
and
(setf 'completing-read 'ido-completing-read)
don't work, at least partly because ido-completing-read
calls completing-read
in its body, so any simple redefinition would result in infinite recursion.
In theory, it should be possible, since the first line of the docstring for ido-completing-read
is "Ido replacement for the built-in completing-read
." I've looked around a bit and can't seem to find anyone else who has attempted or succeeded at it.
I realize that Icicles probably provides something like this, and I may end up going with that anyway, but it is a bit more of a plunge than I care to take right now.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
编辑:现在这是一个 Emacs MELPA 提供的软件包。 它已扩展为成熟的次要模式。 开发在 GitHub 上进行。
原帖:
这是我对雅各布答案的改进。 归功于他最初的魔法。 我添加了一个覆盖变量,您可以使用它来防止在特定函数中使用 ido-completing-read 。 我还添加了一个检查,如果没有完成,则使用原始的完成读取(这种情况偶尔会发生,例如在 org-mode 的 org-remember-apply-template 中,这与 Jacobo 的原始建议)。
哦,要在 Mx 中使用 ido,请使用 amx。
Edit: This is now an Emacs package available from MELPA. It has been expanded into a full-fledged minor mode. Development happens on GitHub.
Original post:
Here is my refinement of Jacobo's answer. Credit to him for the original magic. I've added an override variable, which you can use to prevent the use of
ido-completing-read
in specific functions. I have also added a check that uses the original completing-read if there are no completions (This happens occasionally, for example inorg-remember-apply-template
from org-mode, which breaks with Jacobo's original advice).Oh, and for using ido in M-x, use amx.
戏法,胡言乱语,急!
这适用于除 subr 之外的所有内容,其中最重要的是执行扩展命令(与 Mx 绑定的内容)。 但我们可以从 Mx 得到我们想要的东西
Hocus pocus, abracadabra, presto!
That works with everything but subr's, from which execute-extended-command is the one that matters (what is binded to M-x). But we can get what we want from M-x
我认为 ido-mode 还没有为此做好准备。 特别是,
ido-completing-read
目前仅适用于字符串,而completing-read
也支持列表。 当您想要对要完成的项目有不同的用户级别描述时,这一点非常重要。因此,我对它还不能开箱即用并不感到惊讶。 如果不亲自修改代码,您最好的选择可能就是提交错误报告/功能请求。
I don't think
ido-mode
is ready for this quite yet. In particular,ido-completing-read
currently only works with strings, whilecompleting-read
supports alists as well. This is very important once you want to have a different user-level description of the items you want to complete on.Therefore I am not surprised that it doesn't work out of the box, yet. Short of modifying the code yourself your best bet is probably to just file a bug report/feature request.
Ido 附带了一个可以执行此操作的函数,因此只需在 .emacs 文件中调用它即可:
Ido comes with a function that should do this, so just call it in your .emacs file:
使用 Emacs 24.3,ido-ubiquitous 对我不起作用。 所以尝试了这个,到目前为止效果很好:
Using Emacs 24.3, ido-ubiquitous didn't work for me. So tried this and it is working fine so far:
只是一个想法:您是否尝试过编辑
ido-completing-read
来调用original-completing-read
而不是completing-read
,定义original-completing-read
成为当前的completing-read
然后做你的 defalias 或 setf 事情?Just a thought: have you tried editing
ido-completing-read
to calloriginal-completing-read
instead ofcompleting-read
, definingoriginal-completing-read
to be the currentcompleting-read
and then doing your defalias or setf thing?