I’m much happier with this combination. /usr/local/bin/editor is:
ALTERNATE_EDITOR=/usr/local/bin/editor2 emacsclient -c "$*"
while [ $[ count— ] -gt 0 ]; do
if [ -e $SOCKET ] && [ ! (lsof $SOCKET &> /dev/null) ]; then
$EMACSCLIENT -c “$*”
Among the advantages here over the old one:
emacs —daemon is only run if emacsclient can’t find a socket, as opposed to emacsclient encountering any error
The old one slept for 1 second after launching the daemon. This was occasionally too short, but usually too long. This one checks for the socket five times a second, and gives up after five seconds. (There are imaginable race conditions that could give undesirable results, but I don’t expect to ever actually encounter them.)