TIP_Emacs_server
TIP Starting Emacs server using init.d script
NB
First of all, you must emerge the latest emacs-cvs package, because MultiTTY, though rather stable, has not been included in recent release yet.
emerge emacs-cvs
As Emacs cannot start without console, screen utility will play server role :). So emerge it:
emerge screen
...after successful emerge, put following init.d script in /etc/init.d
| File: /etc/init.d/emacs |
#!/sbin/runscript
#NB: Config is in /etc/conf.d/emacs
serverdir="/tmp/emacs$UID"
emacs=/usr/bin/emacs-23 # Or wherever you installed your multi-tty Emacs
emacs_pid=/var/run/emacs_screen.pid
screen_util=/usr/bin/screen
checkconfig() {
if [ -z "$EMACS_USER" ] || [ -z "$EMACS_INSTANCE" ] ; then
eerror "You need to setup $EMACS_USER and $EMACS_INSTANCE in /etc/conf.d/emacs first"
return 1
fi
if [ ! -e "$screen_util" ] ; then
eerror "You need to emerge screen first."
return 1
fi
}
start() {
checkconfig || return 1
screendir="/var/run/screen/S-$EMACS_USER"
ebegin "Starting emacs server ($EMACS_INSTANCE) instance"
if [ ! -e "$screendir"/*."$EMACS_INSTANCE" ]; then
# Delete leftover
rm -f "$screendir/*.$EMACS_INSTANCE"
if [ -e "$serverdir/$EMACS_INSTANCE" ]; then
# Delete leftover socket (for the wait option)
rm -f "$serverdir/$EMACS_INSTANCE"
fi
fi
start-stop-daemon --start -v -b --chuid $EMACS_USER -x $screen_util \
-p $emacs_pid -m --env HOME=/home/$EMACS_USER --chdir /home/$EMACS_USER \
-- -DmS $EMACS_INSTANCE $emacs -nw -u $EMACS_USER --eval "(setq server-name \"$EMACS_INSTANCE\")" -f server-start
eend ${?}
}
stop() {
ebegin "Stopping emacs server ($EMACS_INSTANCE) instance"
start-stop-daemon --stop -x $screen_util -p $emacs_pid -q
eend ${?}
} |
...and put your options in /etc/conf.d/emacs
| File: /etc/conf.d/emacs |
EMACS_USER="denis" EMACS_INSTANCE="develop" |
- EMACS_USER - your user, emacs will be starting as
- EMACS_INSTANCE - server instance name. So you can start several emacs instances, if you wish
To quick emacs "connect" you may use the following script. Personally, I put it in ~/bin and set PATH appropriately
| File: ~/bin/em-dev |
#!/bin/bash emacsclient -t -s develop $* |
That's all. Happy hacking :)
Last modified: Mon, 08 Sep 2008 11:22:00 +1000 Hits: 1,925
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.
