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

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

问题描述

受堆栈溢出问题的启发 Emacs 中文本的惯用批处理? 我尝试了一个 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 选项不会阻止加载站点启动文件,我有很多

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