[英]Run program with arbitrary filename in emacs
I want to launch an arbitrary program that takes selected filename argument from a buffer that lists files in a directory. 我想启动一个任意程序,该程序从列出目录中文件的缓冲区中获取选定的文件名参数。
I tried to use F3
key to insert the filename but the following records a new macro instead which is rather confusing. 我试图使用
F3
键插入文件名,但是下面记录了一个新的宏,这很令人困惑。
(define-key minibuffer-local-map [f3] (lambda () (interactive (find-file-at-point))))
You're problem is not completely clear to me, but maybe this helps. 您的问题对我来说还不是很清楚,但这也许会有所帮助。
Please see the following screenshot of my Emacs in the scratch buffer. 请在暂存缓冲区中查看我的Emacs的以下屏幕截图。 It contains a function and the keybinding, the echo area at the bottom is showing the results from the call to
message
它包含一个函数和键盘绑定,底部的回显区域显示了调用
message
的结果
For your convenience, here is the function and the keybinding repeated for better copying: 为了您的方便起见,以下是为了更好地复制而重复的功能和键绑定:
(defun command-on-file-at-point ()
(interactive)
(let ((f (ffap-file-at-point)))
(message "File is %s" f)))
(global-set-key [f3] 'command-on-file-at-point)
Hope, that helps. 希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.