Skip to content

Commit f6eacc4

Browse files
committed
Improve documentation of 'server-name'
* doc/emacs/misc.texi (Emacs Server, TCP Emacs server) (emacsclient Options): * lisp/server.el (server-name): Document the usage of 'server-name' to specify the server file as an absolute file name. (Bug#33934)
1 parent fe4922c commit f6eacc4

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

doc/emacs/misc.texi

+18-11
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,9 @@ each one a unique @dfn{server name}, using the variable
16931693
@code{server-name}. For example, @kbd{M-x set-variable @key{RET}
16941694
server-name @key{RET} "foo" @key{RET}} sets the server name to
16951695
@samp{foo}. The @code{emacsclient} program can specify a server by
1696-
name, using the @samp{-s} option (@pxref{emacsclient Options}).
1696+
name, using the @samp{-s} or the @samp{-f} option (@pxref{emacsclient
1697+
Options}), depending on whether or not the server uses a TCP socket
1698+
(@pxref{TCP Emacs server}).
16971699

16981700
If you want to run multiple Emacs daemons (@pxref{Initial Options}),
16991701
you can give each daemon its own server name like this:
@@ -1758,21 +1760,23 @@ use @kbd{M-x server-generate-key} to get a random key.
17581760
When you start a TCP Emacs server, Emacs creates a @dfn{server file}
17591761
containing the TCP information to be used by @command{emacsclient} to
17601762
connect to the server. The variable @code{server-auth-dir} specifies
1761-
the directory containing the server file; by default, this is
1763+
the default directory containing the server file; by default, this is
17621764
@file{~/.emacs.d/server/}. In the absence of a local socket with file
17631765
permissions, the permissions of this directory determine which users
17641766
can have their @command{emacsclient} processes talk to the Emacs
1765-
server.
1767+
server. If @code{server-name} is an absolute file name, the server
1768+
file is created where specified by that file name.
17661769

17671770
@vindex EMACS_SERVER_FILE@r{, environment variable}
17681771
To tell @command{emacsclient} to connect to the server over TCP with
17691772
a specific server file, use the @samp{-f} or @samp{--server-file}
17701773
option, or set the @env{EMACS_SERVER_FILE} environment variable
17711774
(@pxref{emacsclient Options}). If @code{server-auth-dir} is set to a
1772-
non-standard value, @command{emacsclient} needs an absolute file name
1773-
to the server file, as the default @code{server-auth-dir} is
1774-
hard-coded in @command{emacsclient} to be used as the directory for
1775-
resolving relative filenames.
1775+
non-standard value, or if @code{server-name} is set to an absolute
1776+
file name, @command{emacsclient} needs an absolute file name to the
1777+
server file, as the default @code{server-auth-dir} is hard-coded in
1778+
@command{emacsclient} to be used as the directory for resolving
1779+
relative filenames.
17761780

17771781
@node Invoking emacsclient
17781782
@subsection Invoking @code{emacsclient}
@@ -1961,10 +1965,13 @@ evaluation performed is for side-effect rather than result.
19611965

19621966
@item -s @var{server-name}
19631967
@itemx --socket-name=@var{server-name}
1964-
Connect to the Emacs server named @var{server-name}. The server name
1965-
is given by the variable @code{server-name} on the Emacs server. If
1966-
this option is omitted, @command{emacsclient} connects to the first
1967-
server it finds. (This option is not supported on MS-Windows.)
1968+
Connect to the Emacs server named @var{server-name}. (This option is
1969+
not supported on MS-Windows.) The server name is given by the
1970+
variable @code{server-name} on the Emacs server. If this option is
1971+
omitted, @command{emacsclient} connects to the first server it finds.
1972+
If you set @code{server-name} of the Emacs server to an absolute file
1973+
name, give the same absolute file name as @var{server-name} to this
1974+
option to instruct @command{emacsclient} to connect to that server.
19681975

19691976
Alternatively, you can set the @env{EMACS_SOCKET_NAME} environment
19701977
variable to point to the server socket. (The command-line option

lisp/server.el

+8-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,14 @@ been consumed.")
270270
"server")
271271
"The name of the Emacs server, if this Emacs process creates one.
272272
The command `server-start' makes use of this. It should not be
273-
changed while a server is running."
273+
changed while a server is running.
274+
If this is a file name with no leading directories, Emacs will
275+
create a socket file by that name under `server-socket-dir'
276+
if `server-use-tcp' is nil, else under `server-auth-dir'.
277+
If this is an absolute file name, it specifies where the socket
278+
file will be created. To have emacsclient connect to the same
279+
socket, use the \"-s\" switch for local non-TCP sockets, and
280+
the \"-f\" switch otherwise."
274281
:group 'server
275282
:type 'string
276283
:version "23.1")

0 commit comments

Comments
 (0)