The server-running-p predicate will evaluate to t if the Emacs server is running, irrespective of which Emacs session currently "owns" the server process.
Therefore, when there are two or more independent Emacs sessions running simultaneously, server-running-p does not really test whether the current Emacs session is running the server.
I'm looking for a more specific test, one that will evaluate to t if and only if the current session (i.e. the session performing the test) is running the Emacs server.
server-startand afterserver-force-delete),server-modewas alwaysnil. – kjo Mar 04 '17 at 20:32(server-mode 1)rather than calling(server-start). The former invokes the latter, andserver-force-deletealso checks and disables this mode, so it rather looks likesever-modeis the intended interface, and we shouldn't be callingserver-startdirectly. – phils Mar 04 '17 at 23:10server-modestill doesn't account for the same server being started and deleted via multiple Emacs instances, as deleting the server from one instance has no effect on the value ofserver-modein another. – phils Mar 04 '17 at 23:24