50 lines
1.2 KiB
Bash
Executable File
50 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
## Note: we do not use the (-a "") parameters of emacsclient to auto start the
|
|
## daemon since we want to pass additional parameters to emacs.
|
|
|
|
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
|
cat <<EOF
|
|
Usage: ${0##*/} [OPTIONS] [FILES]
|
|
|
|
Start emacsclient in terminal or in X window if possible. If server is not
|
|
found, it is started with --no-site-file parameter.
|
|
|
|
Calling script can have different names.
|
|
* emc: emacs instance is opened in current terminal.
|
|
* emw: if graphical, tell client to wait.
|
|
|
|
When starting the server, the EMACS_SERVER variable is set so that Emacs can
|
|
know in its initialization file whether the server is going to be started.
|
|
|
|
All emacsclient(1) options are supported:
|
|
|
|
$(emacsclient --help)
|
|
|
|
Extra options:
|
|
|
|
--kill: Shutdown Emacs daemon.
|
|
|
|
EOF
|
|
exit
|
|
fi
|
|
|
|
if [ "$1" = "--kill" ]; then
|
|
emacsclient -e '(kill-emacs)'
|
|
exit
|
|
fi
|
|
|
|
|
|
if [ "${0##*/}" = "emc" ] || [ -z "$DISPLAY" ] || \
|
|
[ "$(emacs --batch -Q --eval='(if (fboundp '"'"'tool-bar-mode) (message "X") (message "TTY"))' 2>&1)" = TTY ]; then
|
|
param="-t"
|
|
else
|
|
if [ "${0##*/}" = "emw" ]; then
|
|
param="-c"
|
|
else
|
|
param="-nc"
|
|
fi
|
|
fi
|
|
|
|
[ ! -e "/tmp/emacs$(id -u)/server" ] && EMACS_SERVER=t emacs --daemon --no-site-file
|
|
emacsclient $param "$@"
|