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

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

问题描述

由Stack 溢出问题启发 Emacs中文本的批量处理? / a>我尝试了一个Emacs shell脚本,标题如下:

 #!/ usr / bin / emacs --script 

我把一些Emacs的Lisp代码保存在文本文件rcat中。



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

 载入/etc/emacs/site-start.d/20apel.el(source)... 
加载/etc/emacs23/site-start.d/35elib-startup.el (来源)...
加载/etc/emacs23/site-start.d/50auctex.el(来源)...

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

  rcat --no-site-file 
/ pre>

  rcat -Q 

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

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

有没有办法在这样的脚本文件中传递附加选项到Emacs,而不是稍后在命令行中执行?

解决方案

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

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

如果这不适合您,或者如果您希望您的脚本可移植,请参阅吉尔斯的答案是低于一个更强大的(稍微有趣:)的方法。


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 

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

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)...

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

rcat --no-site-file

or

rcat -Q

but not by changing the headline in the script:

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

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

解决方案

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 "$@"

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天全站免登陆