with-editor chooses the wrong socket location under systemd-socket-activation
OnkelUlla opened this issue · 1 comments
I changed my workflow recently and switched to a socket activated emacs daemon that gets started via the following socket-unit
[Socket]
ListenStream=%t/emacs/server/default
[Install]
WantedBy=sockets.target
where I explicitely choose ${XDG_RUNTIME_DIR}/emacs/server/default
as the location for systemd's user instance to create the socket. Of course the emacs daemon has no knowledge at all of its location as it gets handed over a ready to use file descriptor. As a result with-editor
assumes it to be at the standard location as this is what server-name
("server") and server-socket-dir
("/tmp/emacs<UID>") tells it. As it has no chance at all to get the needed information by itself I manually correct those variables after the emacs daemon started up initially by evaluating
(setq server-socket-dir (substitute-in-file-name "${XDG_RUNTIME_DIR}/emacs/server"))
(setq server-name "default")
which seem to resolve the problem. As I am an absolut emacs lisp noob I do not know how to put this into my init.el
in the way emacs needs the information. Doing it in a dumb way it does not start up at all as it is thinking that there is another instance of emacs daemon already running (which in fact is only the socket that is already created by the systemd socket-unit). I think there could be some kind of configuration parameter for the with-editor
package that is used in this special case.
the socket. Of course the emacs daemon has no knowledge at all of its location as it gets handed over a ready to use file descriptor. As a result
with-editor
assumes it to be at the standard location as this is whatserver-name
("server") andserver-socket-dir
("/tmp/emacs<UID>") tells it.
It seems to me that if something™ manages to get server.el
to use a certain file descriptor and that causes certain server-*
variables to become invalid, then something™ should also take care of setting these variables to the correct values.
I don't know anything about systemd and how it would do that. I also don't know whether this setup is already supposed to take care of this but you somehow managed to misconfigure it.
In any case I think you should ask the maintainers of that setup or some experts for help, as I cannot really help you, knowing next to nothing about systemd.
As I am an absolut emacs lisp noob I do not know how to put this into my
init.el
in the way emacs needs the information.
I also don't know what you are doing wrong, if anything. Please ask on e.g. /r/emacs or https://emacs.stackexchange.com for help. There might be experts around who can help you quickly. I really have no idea but all this either. It doesn't seem like this is specific to with-editor
-- that is just the victim of things not working as expected, not the cause.