使用预定义的lisp代码从shell启动emacs

时间:2013-08-03 13:08:50

标签: shell emacs lisp

可以从shell启动emacs并告诉它执行lisp函数,例如

emacs -f some-lisp-function my_file.py

但是,我想通过参数传递lisp函数,比如

emacs -f "(goto-line 10)" my_file.py
# --> not working

并且在最好的世界中,传递更复杂的包含多个函数调用的lisp代码,例如

emacs -f "(goto-line 10) (some-other-func some-arg)" my_file.py
# --> not working

有人知道怎么做?

编辑:为了澄清这一点,我需要一种方法来评估文件自己的缓冲区中的lisp代码,打开它之后。

(顺便说一句。我知道goto-line问题可以在不使用-f的情况下以不同的方式解决,但这只是我一般问题的一个例子)

2 个答案:

答案 0 :(得分:6)

试试emacs my_file.py --eval '(progn (goto-line 10) (some-other-func some-arg))'。另请注意,将{Emacs调用为emacs +10 my_file.py将在第十行打开文件。

答案 1 :(得分:2)

您可以访问调用Emacs的命令行。您可以添加代码来处理自己的命令行开关。根据您的需要,这可能比--eval更清晰。请参阅http://www.gnu.org/software/emacs/manual/html_node/elisp/Command_002dLine-Arguments.htmlEmacs custom command line argument

相关问题