I would like to have emacsclient
connect to a given Emacs server from command line. Reading the manual Using Emacs as a Server I thought I could do something like:
emacs --eval '(server-start)' --eval "(set-variable 'server-name \"foo\")" --no-splash fileA &
and then later:
emacsclient -s "foo" -n fileB
But this gives error:
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
emacsclient: error accessing socket "foo"
However, I can do:
emacsclient -e '(prin1 server-name)'
which gives
"foo"
You must set the name before you start the server:
emacs --eval '(setq server-name "foo")' --eval '(server-start)' --no-splash fileA &