Emacs 自定义命令行参数 [英] Emacs custom command line argument
问题描述
从文档中我可以看到我可以访问命令行参数 (command-line-args).我想添加我自己的参数,但 Emacs 在启动时抱怨它无法识别它们.
例如
emacs -my_argument
我明白了:
<前>命令行 1:未知选项 `-my_argument'定义我的自定义参数并向我的 Emacs 会话提供信息的正确方法是什么?有没有办法从命令行弹出参数?
将类似的内容添加到您的 ~/.emacs
、~/.emacs.el
或~/.emacs.d/init.el
文件:
(defun my-argument-fn (switch)(消息我通过了 -my_argument"))(添加到列表'command-switch-alist'(-my_argument".my-argument-fn))
然后你可以执行 emacs -my_argument
并且它应该打印 i was connected -my_argument
到 minibuffer.您可以在 GNU elisp 参考.
From the documentation I can see I can access command line arguments (command-line-args). I'd like to add my own arguments but Emacs complains at start up that it doesn't recognize them.
E.g.
emacs -my_argument
I get:
command-line-1: Unknown option `-my_argument'
What's a proper way to define my custom arguments and provide information to my Emacs session? Is there a way to pop an argument from a command line?
Add something like this to your ~/.emacs
, ~/.emacs.el
, or ~/.emacs.d/init.el
file:
(defun my-argument-fn (switch)
(message "i was passed -my_argument"))
(add-to-list 'command-switch-alist '("-my_argument" . my-argument-fn))
Then you can execute emacs -my_argument
and it should print i was passed -my_argument
to the minibuffer. You can find more information in the GNU elisp reference.
这篇关于Emacs 自定义命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!