Evaluate emacs lisp expression on command line

后端 未结 2 898
难免孤独
难免孤独 2021-02-08 12:33

I\'m a newbie to emacs. I\'m working with emacs-24.1 on redhat linux, and trying to evaluate an elisp expression. What I want emacs to do is to evaluate the elisp expression wit

相关标签:
2条回答
  • 2021-02-08 13:08

    Try

    emacs --batch --eval '(print (+ 2 3))'
    
    0 讨论(0)
  • 2021-02-08 13:23

    After a bit of testing it looks like you can use --batch to have emacs dump any messages to stderr. Then you can call message to print things to stderr where you'll be able to see them. Your example would become emacs --batch --eval '(message (number-to-string (+ 2 3)))' and the result would be printed to stderr.

    If you're trying to redirect the output to a file you'll need to redirect stderr instead of stdout by using 2> instead of just >.

    0 讨论(0)
提交回复
热议问题