7

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.

Joe
  • 1,312
  • 1
  • 8
  • 19

1 Answers1

7

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)'
Dan
  • 32,584
  • 6
  • 98
  • 168
  • 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 Aug 03 '16 at 03: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 Aug 03 '16 at 13:34
  • Ah, I had a zombie emacs process that was intercepting emacsclient. It now works like a charm – Joe Aug 04 '16 at 03:13