开发者

Hook for tab completion in emacs (interactive) file input?

开发者 https://www.devze.com 2022-12-17 22:29 出处:网络
In emacs, the following will define a function that, when called interactively, will ask the user for a 开发者_运维知识库filename:

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消