emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add support in emacsclient for EMACS_SOCKET_NAME


From: Daniel Pittman
Subject: [PATCH] Add support in emacsclient for EMACS_SOCKET_NAME
Date: Wed, 5 Sep 2018 10:38:47 -0400

If the `--socket-name` argument is unspecified, the environment
variable `EMACS_SOCKET_NAME` is now consulted with the same
semantics. This mirrors the behavior of the `--server-file` argument,
and allows for easier configuration of emacsclient when the socket is
in a location other than `TMPDIR` or `/tmp`.

* emacsclient.c (set_socket):
Add support for the EMACS_SOCKET_NAME environment variable.
* misc.texi (emacsclient Options):
* emacsclient.1:
Document the EMACS_SOCKET_NAME environment variable.
---
 doc/emacs/misc.texi   | 4 ++++
 doc/man/emacsclient.1 | 1 +
 etc/NEWS              | 6 ++++++
 lib-src/emacsclient.c | 3 +++
 4 files changed, 14 insertions(+)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 236cb07785..ab33cafb8e 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1966,6 +1966,10 @@ is given by the variable @code{server-name} on the Emacs server.  If
 this option is omitted, @command{emacsclient} connects to the first
 server it finds.  (This option is not supported on MS-Windows.)
 
+Alternatively, you can set the @env{EMACS_SOCKET_NAME} environment
+variable to point to the server socket.  (The command-line option
+overrides the environment variable.)
+
address@hidden -t
address@hidden --tty
address@hidden -nw
diff --git a/doc/man/emacsclient.1 b/doc/man/emacsclient.1
index daaacab7f3..03fad2672c 100644
--- a/doc/man/emacsclient.1
+++ b/doc/man/emacsclient.1
@@ -94,6 +94,7 @@ open a new Emacs frame on the current terminal
 .TP
 .B \-s, \-\-socket-name=FILENAME
 use socket named FILENAME for communication.
+This can also be specified via the EMACS_SOCKET_NAME environment variable.
 .TP
 .B \-V, \-\-version
 print version information and exit
diff --git a/etc/NEWS b/etc/NEWS
index 61b6d4e0e2..fbcf57a718 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -117,6 +117,12 @@ the new version of the file again.)
 
 * Changes in Emacs 27.1
 
++++
+** emacsclient uses EMACS_SOCKET_NAME if --socket-name is not set.
+The behavior is identical to the EMACS_SERVER_FILE, in that the
+command line value will override the environment, and the natural
+default to TMPDIR, then /tmp, continues to apply.
+
 +++
 ** The function 'read-passwd' uses '*' as default character to hide passwords.
 
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 4fe3a588b1..42b8dd6227 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1409,6 +1409,9 @@ set_socket (int no_exit_if_error)
 
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
   /* Explicit --socket-name argument.  */
+  if (!socket_name)
+    socket_name = egetenv ("EMACS_SOCKET_NAME");
+
   if (socket_name)
     {
       s = set_local_socket (socket_name);
-- 
2.18.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]