Subject: Re: bug#1058: 23.0.60; emacs --daemon should not return until socket is ready

From: "Trent W. Buck" <[email-masked]>
Date: Thu, 2 Oct 2008 10:50:21 +1000

On Wed, Oct 01, 2008 at 09:39:40PM +0200, Romain Francoise wrote:
>> Just curious, what do you get if you do: emacs -Q --daemon; while !
>> ls /tmp/emacs1187/; do sleep 1; done
>
> Yes, the delay is caused by my change to load the init file before
> starting the server.

It's vaguely relevant that I have this in my .emacs:

  (progn
    (unless (< emacs-major-version 22)
      ;; Support multiple, concurrent Emacs servers.
      (setq server-name (format "server%d" (emacs-pid)))
      ;; Allow child processes to find the correct one.
      (setenv "EMACS_SOCKET_FILE" server-name)
      ;; Have other processes use the youngest server.
      (defadvice server-start (after multiple-server-start)
        (make-symbolic-link server-name
                            (concat server-socket-dir "/server")
                            t))
      (ad-activate 'server-start))
    (server-start))

and an emacsclient wrapper that includes

    ## In M-x shell always use the focused emacs, even if there are
    ## other Emacs servers.  Requires non-standard $EMACS_SOCKET_FILE,
    ## which is set in my .emacs.  Needs Emacs 22 or better.
    if [[ $EMACS_SOCKET_FILE && $INSIDE_EMACS && $v -ge 22 ]]
    ## With DISPLAY emacsclient tries to pop up an X frame.
    then exec env -u DISPLAY emacsclient -s "$EMACS_SOCKET_FILE" "$@"
    fi