Subject: Re: bug#41707: [PATCH] Try $TMPDIR if $XDG_RUNTIME_DIR has no socket

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 05 Aug 2020 18:30:10 +0200

Adam Edge <[email-masked]> writes:

> Emacsclient currently checks whether $XDG_RUNTIME_DIR exists in
> the environment, and if it does, it uses that as a base for the
> socket directory.  However, Emacs seems to still use $TMPDIR
> when the daemon is started (both via emacs --daemon and
> M-x start-server).  This commit makes Emacsclient first check
> whether the socket exists in $XDG_RUNTIME_DIR, and if it doesn't,
> fall back to $TMPDIR.

As far as I can see, Emacs uses the XDG directory:

;; We do not use `temporary-file-directory' here, because emacsclient
;; does not read the init file.
(defvar server-socket-dir
  (if internal--daemon-sockname
      (file-name-directory internal--daemon-sockname)
    (and (featurep 'make-network-process '(:family local))
	 (let ((xdg_runtime_dir (getenv "XDG_RUNTIME_DIR")))
	   (if xdg_runtime_dir
	       (format "%s/emacs" xdg_runtime_dir)
	     (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))))))
  "The directory in which to place the server socket.
If local sockets are not supported, this is nil.")

If your Emacs doesn't, then that seems like a bug that should be fixed,
instead of changing emacsclient to check both directories?

Or perhaps you're running a different version of Emacs and emacsclient?
That often has problems and isn't recommended.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no