就是说,不需要打开emacs,在term的命令行模式下就能用 emacs --batch 什么什么的命令?
emacs --batch -f <your-update-function>
thanks a lot, but emacs --batch -f configuration-layer/update-packages
doesn’t work.
you may need emacs --batch --eval '(configuration-layer/update-packages t)'
because it requires a confirm operation by default.
谢谢你,应该是这个函数不支持的缘故
$ emacs --batch --eval '(configuration-layer/update-packages t)'
Symbol’s function definition is void: configuration-layer/update-packages
这个函数从哪里来?你不能凭空调用一个函数。
update 最关键的是:知道哪些 package 需要更新
当你正常启动的时候,你的配置文件搜集到了所有信息,所以你可以调用 xxx-update
。
当你以 batch 模式运行,也必须能搜集到同样的信息,并且有 xxx-update
可供调用。
我的做法是(自己从 0 开始的配置),准备一个 init-dl.el
,它跟 init.el
一样提供启动所需的接口。区别在于它只收集/解析 package 的信息,其它接口都是虚的,没有实质作用,只是为了让整个配置文件能跑起来:
emacs --batch -l init-dl.el
如果你的配置没有考虑到命令行更新,那就直接 batch 模式完整加载,只不过多花些时间罢了:
emacs --batch -l init.el -f xxx-update
必须确保 batch 模式和正常启动得到的 package 一致。
如果你的配置在安装包的时候,有针对 GUI 和 Terminal 做区别对待,那么就要注意了。
1 个赞