2013-07-10 18:31:13 +02:00
|
|
|
#!/bin/sh
|
2014-02-23 19:01:36 +01:00
|
|
|
## Note: we do not use the (-a "") parameters of emacsclient to auto start the
|
|
|
|
## daemon since we want to pass additional parameters to emacs.
|
2013-07-10 18:31:13 +02:00
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
if [ "$1" = "-h" ]; then
|
|
|
|
cat <<EOF>&2
|
2016-10-13 12:06:13 +02:00
|
|
|
Usage: ${0##*/} [OPTIONS] [FILES]
|
2014-04-22 16:34:17 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2015-04-19 12:18:54 +02:00
|
|
|
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.
|
|
|
|
|
2016-10-13 12:06:13 +02:00
|
|
|
All emacsclient(1) options are supported:
|
2014-04-22 16:34:17 +02:00
|
|
|
|
|
|
|
$(emacsclient --help)
|
|
|
|
|
2016-10-13 12:06:13 +02:00
|
|
|
Extra options:
|
|
|
|
|
|
|
|
--kill: Shutdown Emacs daemon.
|
|
|
|
|
2014-04-22 16:34:17 +02:00
|
|
|
EOF
|
2014-11-12 16:15:39 +01:00
|
|
|
exit
|
2014-04-22 16:34:17 +02:00
|
|
|
fi
|
|
|
|
|
2016-10-13 12:06:13 +02:00
|
|
|
if [ "$1" = "--kill" ]; then
|
|
|
|
emacsclient -e '(kill-emacs)'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-04-22 16:34:17 +02:00
|
|
|
if [ "${0##*/}" = "emc" ] || [ -z "$DISPLAY" ] || \
|
2014-11-12 16:15:39 +01:00
|
|
|
[ "$(emacs --batch -Q --eval='(if (fboundp '"'"'tool-bar-mode) (message "X") (message "TTY"))' 2>&1)" = TTY ]; then
|
|
|
|
param="-t"
|
2013-07-10 18:31:13 +02:00
|
|
|
else
|
2014-11-12 16:15:39 +01:00
|
|
|
if [ "${0##*/}" = "emw" ]; then
|
|
|
|
param="-c"
|
|
|
|
else
|
|
|
|
param="-nc"
|
|
|
|
fi
|
2013-07-10 18:31:13 +02:00
|
|
|
fi
|
2014-02-23 19:01:36 +01:00
|
|
|
|
2016-06-23 23:18:36 +02:00
|
|
|
[ ! -e "/tmp/emacs$(id -u)/server" ] && EMACS_SERVER=t emacs --daemon --no-site-file
|
2014-02-23 19:01:36 +01:00
|
|
|
emacsclient $param "$@"
|