可以从 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 代码,在打开它之后。
(顺便说一句。我知道可以在不使用 -f
的情况下以不同的方式解决 goto-line 问题,但这只是我的一般问题的一个例子)
最佳答案
试试 emacs my_file.py --eval '(progn (goto-line 10) (some-other-func some-arg))'
。另请注意,将 Emacs 调用为 emacs +10 my_file.py
将在第十行打开文件。
关于shell - 使用预定义的 lisp 代码从 shell 启动 emacs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18033190/