Subject: 24.2.91; emacsclient doesn't find server with nonstandard name

From: Michael Heerdegen <[email-masked]>
Date: Mon, 31 Dec 2012 18:11:18 +0100

Hi,

In emacs -Q, do this:

(progn
  (require 'server)
  (let ((server-name (concat "server_" (format-time-string  "%H:%M:%S"))))
    (server-start)))

Then I try to connect to this server, but it fails:

| bash-4.2:mh:~$ /usr/bin/emacsclient ~/.bashrc 
| /usr/bin/emacsclient: can't find socket; have you started the server?
| To start the server in Emacs, type "M-x server-start".
| /usr/bin/emacsclient: No socket or alternate editor.  Please use:
| 
|         --socket-name
|         --server-file      (or environment variable EMACS_SERVER_FILE)
|         --alternate-editor (or environment variable ALTERNATE_EDITOR)

When I explicitly specify the server name with the -s option,
emacsclient succeeds.  But due to the doc (man page), "emacsclient"
should connect to "the first server it finds":

| `-s SERVER-NAME'
| `--socket-name=SERVER-NAME'
|      Connect to the Emacs server named SERVER-NAME.  The server name is
|      given by the variable `server-name' on the Emacs server.  If this
|      option is omitted, `emacsclient' connects to the first server it
|      finds.  (This option is not supported on MS-Windows.)

Obviously this is not fulfilled here.  And it is no useful behavior.  If
only one server is running (and the socket is located under the
canonical path), emacsclient should find and use it.  It is arguable
which server should be used if more than one is running (and what the
"first server it finds" should be).

BTW, here is an explanation for why I want to start the server like
above (not substantially important for this report):

I often make changes to my config file/ elpa installations or rebuild
Emacs.  To guarantee that I always have a running Emacs (as a fallback
when something went wrong and a newly started Emacs fails to start), I
keep my old Emacs open and start a new one.  If I had just

  (server-start)

in my config, the new Emacs would not start a server (since the old one
is still running).  After having closed the old Emacs, I had no server
running, so I had to manually start the server every time.  This is
annoying.  So I want to start a server with a unique name.

Thanks,

Michael.

In GNU Emacs 24.2.91.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2012-12-30 on drachen
Bzr revision: [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux testing (wheezy)