O que você está procurando é o modo batch do Emacs, que instrui o Emacs a executar o programa Lisp fornecido (seja dado por -l FILE
, -f FUNCTION
ou --eval FORM
), e então saia. Do Manual de referência do Lisu do GNU Emacs :
The command-line option ‘-batch’ causes Emacs to run noninteractively. In this mode, Emacs does not read commands from the terminal, it does not alter the terminal modes, and it does not expect to be outputting to an erasable screen. The idea is that you specify Lisp programs to run; when they are finished, Emacs should exit. The way to specify the programs to run is with ‘-l file’, which loads the library named file, or ‘-f function’, which calls function with no arguments, or ‘--eval form’.
Any Lisp program output that would normally go to the echo area, either using message, or using prin1, etc., with t as the stream, goes instead to Emacs's standard error descriptor when in batch mode. Similarly, input that would normally come from the minibuffer is read from the standard input descriptor. Thus, Emacs behaves much like a noninteractive application program. (The echo area output that Emacs itself normally generates, such as command echoing, is suppressed entirely.)
E para um exemplo rápido:
me@host $ emacs -batch --eval '(message (format "1+2 equals %d" (+ 1 2)))'
1+2 equals 3
me@host $