File: dtemacs

package info (click to toggle)
gnuserv 3.12.8-12
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 832 kB
  • sloc: ansic: 5,138; lisp: 1,572; makefile: 419; sh: 268
file content (33 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
 
# $Id: dtemacs,v 1.2 2004/02/16 11:23:59 benj Exp $

# Try to contact Emacs with gnuclient, starting Emacs if no answer.
# Pass all options to gnuclient.  This version is standalone and doesn't
# need any fancy elisp.

GNUCLIENT=gnuclient
GNUCLIENTPINGOPTIONS="-batch -eval t"
EMACS=emacs
TIMEOUT=20

# If Emacs doesn't seem to be running then make it so.
if ${GNUCLIENT} ${GNUCLIENTPINGOPTIONS} >/dev/null 2>&1 ; then
    :
else
    ${EMACS} -iconic -eval "(setq gnuserv-kill-quietly t)" -f gnuserv-start 2>&1 >/dev/null &
fi
 
# Try for TIMEOUT seconds to talk to the Emacs process.
 
count=0
until ${GNUCLIENT} ${GNUCLIENTPINGOPTIONS} >/dev/null 2>&1 ; do
    if [ ${count} -gt ${TIMEOUT} ] ; then
        echo "dtemacs: error starting Emacs" 1>&2
        exit 1
    fi
    sleep 1
    count=`expr ${count} + 1`
done
 
exec ${GNUCLIENT} ${1+"$@"}