Note that there are some explanatory texts on larger screens.

plurals
  1. POEvaluate emacs lisp expression on command line
    primarykey
    data
    text
    <p>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 without launching emacs itself. I'm trying different things</p> <pre><code>emacs --eval '(+ 2 3)' </code></pre> <p>I do not know if emacs is evaluating the expression, but the result is not shown on console and emacs window comes up. Next I tried this</p> <pre><code>emacsclient --eval '(+ 2 3)' </code></pre> <p>Emacs client is expecting a server. It could not find the server and hence throwing an error (can't find socket. start server etc). So I launched a server (server-name is SERVER) and ran emacsclient again</p> <pre><code>emacsclient --server-file=SERVER -e '(+ 2 3)' </code></pre> <p>This time, emacs evaluated the expression and printed the result on console. That is because emacs is using the existing server to evaluate the expression. Now I get a problem when the server is not running.</p> <pre><code>emacsclient --server-file=ANOTHER_SERVER -e '(+ 2 3)' -a emacs </code></pre> <p>This time, I'm not getting any error on console. Emacs is launching a new window, because of -a (my .emacs has (server-start) command in it and server-name set to ANOTHER_SERVER). But emacs then is trying to edit the file (+ 2 3). It is shown on the mode line. I'm confused. emacsclient --help showed me this</p> <pre><code>-e, --eval Evaluate the FILE arguments as ELisp expressions </code></pre> <p>and emacs manual says this.</p> <pre><code>'-e' '--eval' Tell Emacs to evaluate some Emacs Lisp code, instead of visiting some files. When this option is given, the arguments to emacsclient are interpreted as a list of expressions to evaluate, not as a list of files to visit. </code></pre> <p>I do not know how to proceed on this. As I said, my goal is to evaluate an elisp expression without launching emacs. Is it possible?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload