在 emacs(交互式)文件输入中挂钩制表符补全?
在 emacs 中,以下将定义一个函数,当交互调用时,该函数将询问用户一个文件名:
(defun do-something (filename )
(interactive "FFilename: ")
...
)
当用户输入文件名时,他们可以使用制表符完成等。有谁知道其中是否有任何钩子文件输入代码?特别是,我想修改我的 find-file 命令,以便在您按 Tab 时 Windows 符号链接(显示为“foo.lnk”)会自动跟随到其目标。
我目前正在使用 w32-symlinks,意味着至少如果我在链接上按 Enter 键,那么它将在 diredit 中打开目标。但我更希望能够通过制表符完成我正在查看的文件,而不是打开 diredit 然后执行第二个 find-file 命令。
In emacs, the following will define a function that, when called interactively, will ask the user for a filename:
(defun do-something (filename )
(interactive "FFilename: ")
...
)
When the user is entering a filename, they can use tab-completion, etc. Does anyone know if there are any hooks in that file-entry code? In particular, I would like to modify my find-file command so that windows symlinks (which show up as "foo.lnk") are automatically followed to their target if you hit tab.
I'm currently using w32-symlinks, which means that at least if I hit enter on the link, then it will open up the target in diredit. But I'd prefer to be able to just tab-complete through it to the file I'm looking at, rather than opening diredit and then doing a second find-file command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在重新发明轮子之前,也许将 (ido-mode t) 放入您的 .emacs 文件中,看看它是否符合您的要求。
我不使用 Windows,但我使用 ido,它比默认的好得多。
Before reinventing the wheel, perhaps put (ido-mode t) in your .emacs file and see if it does what you are wanting.
I dont use windows, but I use ido and it is much nicer than default.
一般来说,您的问题的答案是直接在
interactive
规范中使用completing-read
——不要使用字符串参数。 IOW,编写您自己的完成集。或者,您可以将 read-file-name-function 绑定到您自己的函数,该函数执行文件名完成(例如,合并标准行为)。请参阅标准库
minibuffer.el
。The answer to your question in general is to use
completing-read
directly in theinteractive
spec -- don't use a string argument. IOW, compose your own set of completions.Or you can bind
read-file-name-function
to your own function which performs file-name completion (and, e.g., incorporates the standard behavior). See standard libraryminibuffer.el
.