在 emacs(交互式)文件输入中挂钩制表符补全?

发布于 2024-08-18 08:08:22 字数 500 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神爱温柔 2024-08-25 08:08:22

在重新发明轮子之前,也许将 (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.

空‖城人不在 2024-08-25 08:08:22

一般来说,您的问题的答案是直接在interactive规范中使用completing-read——不要使用字符串参数。 IOW,编写您自己的完成集。

或者,您可以将 read-file-name-function 绑定到您自己的函数,该函数执行文件名完成(例如,合并标准行为)。请参阅标准库 minibuffer.el

The answer to your question in general is to use completing-read directly in the interactive 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 library minibuffer.el.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文