I want to write a script that "links" an emacs server to a certain directory. To do so I need to check all existing servers to be sure if a server with a specific name is running or not. Then the script can decide to start a new server, or not, before opening a file from that directory using emacsclient.
I have been looking around to find out how to list the existing emacs running servers, unsuccessfully though.
Is there anything like emacs --list-servers
that I could use?
Cheers.
Emacs stores the socket files for all running servers in
${TMPDIR}/emacs$(id -u)
, where$TMPDIR
defaults to/tmp
if unset. Find all running servers is as simple as listing all sockets in that directory.In Bash, this would look roughly like
The
servers
array now contains the names of all running Emacs servers, for use withemacslcient -s
.Edit: Since you're using Python apparently, the same in Python: