我正在尝试找到一种方法来自动接受来自 minibuffer 的第一个提案。
(defun find-file-at-point-without-prompt ()
(interactive )
(find-file-at-point)
)
调用结果提示:“ Find file or URL: ......
”。我只想要一个自动的“是”。
传递参数不起作用。对于其他情况也可能很有趣。在此之前我使用了一个宏,它只会调用 find-file-at-point 后跟一个 RET。
似乎没有变量可以自动接受提示。
您可以ffap-read-file-or-url
通过删除正在执行提示的部分来重新定义功能。它仍然是这样的
(defun ffap-read-file-or-url (prompt guess)
"Read file or URL from minibuffer, with PROMPT and initial GUESS."
(or guess (setq guess default-directory))
(let (dir)
;; Tricky: guess may have or be a local directory, like "w3/w3.elc"
;; or "w3/" or "../el/ffap.el" or "../../../"
(or (ffap-url-p guess)
(progn
(or (ffap-file-remote-p guess)
(setq guess
(abbreviate-file-name (expand-file-name guess))
))
(setq dir (file-name-directory guess))))
;; Do file substitution like (interactive "F"), suggested by MCOOK.
(or (ffap-url-p guess) (setq guess (substitute-in-file-name guess)))
;; Should not do it on url's, where $ is a common (VMS?) character.
;; Note: upcoming url.el package ought to handle this automatically.
guess))