#!/bin/sh
# This script launches emacs using the emacsclient program.
# If necessary, emacs is started
. `dirname $0`/Config
echo USE_CLIENT=$USE_CLIENT
function start_emacs {
    local start_server
    [ -z "$USE_CLIENT" ] || start_server="-eval '(server-start)'"
    eval emacs $start_server $@
}
    
if [ -z "$USE_CLIENT" ] ; then
    emacs $@
else
    if [ -z "$1" ] || ! emacsclient $@ 2>/dev/null ; then
        start_emacs $@
    fi
fi
