Emacs自定义命令行参数 [英] Emacs custom command line argument

查看:115
本文介绍了Emacs自定义命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从文档中我可以看到我可以访问命令行参数(command-line-args)。
我想添加自己的论据,但是Emacs在启动时抱怨说它不能识别他们。



例如。

  emacs -my_argument 

我得到:

 
command-line-1:未知选项`-my_argument'

什么是定义自定义参数并向我的Emacs会话提供信息的正确方法?
有没有办法从命令行弹出参数?

解决方案

将这样的东西添加到你的〜/ .emacs 〜/ .emacs.el 〜/ .emacs.d / init.el 文件:

 (defun my-argument-fn(switch)
(消息我被通过了-my_argument))

(add-to-list'command-switch-alist'(-my_argument。my-argument-fn))

然后你可以执行 emacs -my_argument ,它应该打印code>我已经通过-my_argument 到minibuffer。您可以在 GNU elisp参考资料中找到更多信息。 a>。


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆