Emacs shell脚本 - 如何将初始选项放入脚本? [英] Emacs shell scripts - how to put initial options into the script?

查看:353
本文介绍了Emacs shell脚本 - 如何将初始选项放入脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

受到Stack&Overflow问题的启发 Emoms中的文本的Idomatic批处理?我尝试了一个带有以下标题的Emacs shell脚本:

Inspired by Stack Overflow question Idomatic batch processing of text in Emacs? I tried out an Emacs shell script with the following headline:

#!/usr/bin/emacs --script 

我在里面放了一些Emacs的Lisp代码,并将其保存为文本文件rcat。

I put some Emacs Lisp code in it, and saved it as textfile rcat.

由于--script选项不阻止加载site-start文件,我有很多

Since the --script option does not prevent the loading of the site-start file, I had a lot of

Loading /etc/emacs/site-start.d/20apel.el (source)...
Loading /etc/emacs23/site-start.d/35elib-startup.el (source)...
Loading /etc/emacs23/site-start.d/50auctex.el (source)...

在Bash shell(stdout)中的消息。我可以通过调用

messages in the Bash shell (stdout). I can prevent that by calling

rcat --no-site-file

rcat -Q

,但不是通过更改脚本中的标题:

but not by changing the headline in the script:

 #!/usr/bin/emacs --script --no-site-file

有没有办法在这样的脚本文件中向Emacs传递额外的选项,而不是在命令行上执行?

Is there a way to pass additional options to Emacs inside such a script file instead of doing it later on the commandline?

推荐答案

您可以随时将#!/ usr / bin / emacs 更改为#!/ home / thorsten / bin / emacs-no -site-file ,并设置为:

You could always change #!/usr/bin/emacs to something like #!/home/thorsten/bin/emacs-no-site-file, and set that up as:

#!/bin/sh
exec /usr/bin/emacs --no-site-file "$@"

这不适合您,或者如果您希望您的脚本可移植,请参阅 Gilles的回答如下一个更强大(和稍微时髦:)方法。

If this doesn't work for you, or if you wish your script to be portable, then see Gilles' answer below for a more robust (and slightly funky :) approach.

这篇关于Emacs shell脚本 - 如何将初始选项放入脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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