How can I execute elisp in the currently running emacs from the command line?

The following command echoes 'hi' but doesn't set 'abc in the emacs instance.

emacsclient --no-wait --eval '(message "hi") (setq abc)'

Is there a way to modify emacs from the command line?

My specific use case is to revert all buffers with a shell command.

1 Answer 1


You can either wrap your two forms in a progn:

emacsclient --no-wait --eval '(progn (message "hi") (setq abc 123))'

Or you can send them separately:

emacsclient --no-wait --eval '(message "hi")' '(setq def 456)'
  • I don't think the quoting matters. Either way, abc is not defined in emacs. The goal is for abc to be defined in the currently open emacs.
    – Joe
    Commented Aug 3, 2016 at 3:55
  • 1
    I just tried it and both of the options listed work on my machine. You're sure you've got the server running?
    – Dan
    Commented Aug 3, 2016 at 13:34
  • Ah, I had a zombie emacs process that was intercepting emacsclient. It now works like a charm
    – Joe
    Commented Aug 4, 2016 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.