Emacs daemon memo

Run named daemon

Emacs --daemon command line option can accept name argument(like --daemon=server1).

% emacs --daemon=vim -Q
% emacs --daemon=atom -Q

Sending S-expression via emacsclient

And we can specify server by -s(--socket-name) option of emacsclient as below. (We can also specify socket file path instead of daemon name)

% emacsclient -s vim -e '(emacs-pid)'
% emacsclient -s atom -e '(shell-command-to-string "vim --version")'

Shutdown emacs daemon

We can stop daemon by sending kill-emacs

% emacsclient -s vim -e '(kill-emacs)'

If you stop emacs daemon by kill command, you should also remove socket file at ${temporary-file-directory}/emacs${pid}/${servername} such as /tmp/emacs1000/vim.