Subject: Re: bug#24218: 25.1.50; server-name, server-socket-dir and daemon start through, systemd socket

From: Matthew Leach <[email-masked]>
Date: Tue, 09 Jan 2018 19:53:03 +0000

Eli Zaretskii <[email-masked]> writes:

>> From: Paul Eggert <[email-masked]>
>> Date: Sun, 7 Jan 2018 13:55:04 -0800
>> Cc: [email-masked], Vladimir Lomov <[email-masked]>
>> 
>> Matthew proposed a patch for this here:
>> 
>> https://lists.gnu.org/r/emacs-devel/2017-12/msg00903.html
>> 
>> which I am attaching in git form (see first attached patch). I also 
>> propose the second attached patch as a followup. It makes some of the 
>> newly-added features "private" (since they don't seem to be generally 
>> useful) and moves the low-level initialization code from emacs.c to 
>> process.c which is a more-natural home for it.

Thanks for the cleanup patch Paul!

>
> Thanks.  I'm not an expert on this stuff, so I have only minor
> comments:
>
>   . Please update the :version tag of server-name, to reflect the fact
>     that its default value changes
>   . This needs a NEWS entry, and I think the description of
>     server-name in the manual should be updated to mention this
>     facility

Please see the attached patch that should address these points.

>   
>   . internal--external-sockname should be documented in the ELisp
>   manual (a better name that doesn't use both "internal" and
>   "external" will be appreciated)

May I suggest `internal--daemon-sockname'?

Thanks,
-- 
Matt

>From 5dc51350e7e744f26236e0018112d2eed2dbcc93 Mon Sep 17 00:00:00 2001
From: Matthew Leach <[email-masked]>
Date: Tue, 9 Jan 2018 19:45:30 +0000
Subject: [PATCH] Update `server-name' :version tag and document sockname
 support

* lisp/server.el: (server-name): Update :version tag.
* etc/NEWS: Document that `server-name' and `server-socket-dir'
  automatically update.
* doc/misc.texi: (Emacs Server): Likewise.
---
 doc/emacs/misc.texi | 5 +++++
 etc/NEWS            | 3 +++
 lisp/server.el      | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 633e1e881d..c9b8f08252 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1654,6 +1654,11 @@ Emacs Server
 @samp{foo}.  The @code{emacsclient} program can specify a server by
 name, using the @samp{-s} option (@pxref{emacsclient Options}).
 
+  If Emacs is passed a socket by an external program --- for example
+by systemd socket activation --- the value of @code{server-name} and
+@code{server-socket-dir} is automatically updated to reflect the name
+and path of the socket.
+
   If you want to run multiple Emacs daemons (@pxref{Initial Options}),
 you can give each daemon its own server name like this:
 
diff --git a/etc/NEWS b/etc/NEWS
index f6f36dfc85..66cb0834c5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -194,6 +194,9 @@ as new-style, bind the new variable 'force-new-style-backquotes' to t.
 
 * Lisp Changes in Emacs 27.1
 
+** The `server-name' and `server-socket-dir' variables are set when a
+socket has been pased to Emacs (Bug#24218).
+
 ** Internal parsing commands now use syntax-ppss and disregard
 open-paren-in-column-0-is-defun-start.  This affects mostly things like
 forward-comment, scan-sexps, and forward-sexp when parsing backward.
diff --git a/lisp/server.el b/lisp/server.el
index c867fde832..16b3f8e4e2 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -266,7 +266,7 @@ server-name
 changed while a server is running."
   :group 'server
   :type 'string
-  :version "23.1")
+  :version "27.1")
 
 ;; We do not use `temporary-file-directory' here, because emacsclient
 ;; does not read the init file.
-- 
2.15.1