Subject: [patch] add support for emacs daemon on Windows
From: Mark Laws <[email-masked]>
To: [email-masked]
Date: Mon, 26 Jan 2015 04:18:34 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I am not on this list so please CC me in any replies.

Attached is a patch which should apply cleanly on top of master
(a3689d3c661fe36df971c875760f8d500b5ae994 as of this email). It allows
Emacs to run as a daemon on Windows. Without daemon mode, emacsclient
-a "" does not work, which makes it impossible to pass elisp to Emacs
via emacsclient unless Emacs is already running. In other words, this
will now work correctly:

emacsclient -a "" -e "(ediff-merge-files-with-ancestor ...)"

Previously, -a "" produced an error message on Windows. There was no
workaround, because:

emacs -a emacs -e "(ediff-merge-files-with-ancestor ...)"

would start a new Emacs with a buffer called
"(ediff-merge-files-with-ancestor ...)".

The functionality is identical to the UNIX implementation with one
difference: I didn't allow for running multiple/named daemons. The
reason I didn't was because the code for that in emacsclient.c took
the daemon name from the socket name if one was provided, and because
filesystem sockets are not supported on Windows, I couldn't think of a
way to provide identical behavior across UNIX and Windows.

This patch has been heavily tested against emacs-24 without any
issues; it seems to work well against master as well.

Thanks to Eli Zaretskii for help with debugging.

Cheers,
Mark Laws

-- 
|v\ /\ |\ |< |_ /\ \^| //