|
|
发表于 2006-5-11 02:42:09
|
显示全部楼层
u're welcome, pluskid
I bet you haven't read the README from the multi-tty patch. The author actually provided two very useful shell script: preload-emacs and connect-emacs (see below) to keep an emacs-server running in a detached GNU Screen session ( http://www.gnu.org/software/screen/ ). This way you have your emacs server running through different X sessions or even after logging off. This is what I meant `one startup per boot' in the other post.
As to c-x c-c. I think it is now bound to save-buffer-kill-terminal by default, instead of save-buffer-kill-emacs for the unpatched branch. so there is no risk invoking it -- only killing the last terminal will you kill the whole emacs, and if u use screen, as is described above, there is hardly a chance.
btw, I myself use dtach ( http://dtach.sourceforge.net/ ) instead. screen is great, but it's an overkill for maintaining a server frame in background that i'll never visit.
below are the mentioned scripts.
preload-emacs (adapted for dtach):#!/bin/bash
# Usage: preload-emacs <name> [<waitp>]
#
# Preloads the Emacs instance called NAME in a detached screen
# session. Does nothing if the instance is already running. If WAITP
# is non-empty, the function waits until the server starts up and
# creates its socket; otherwise it returns immediately.
name="$1"
waitp="$2"
dtachdir=~/.dtach_socks #pick up your own
screendir="/var/run/screen/S-$USER"
serverdir="/tmp/emacs$UID"
emacs="/usr/local/bin/emacs" # Or wherever you installed your multi-tty Emacs
if [ -z "$name" ]; then
echo "Usage: preload_emacs <name> [<waitp>]" >&2
exit 1
fi
#if [ ! -e "$screendir"/*."$name" ]; then
if [ ! -e "$dtachdir"/"$name" ]; then
if [ -e "$serverdir/$name" ]; then
# Delete leftover socket (for the wait option)
rm "$serverdir/$name"
fi
# screen -dmS "$name" "$emacs" -nw --no-splash --eval "(setq server-name \"$name\")" -f server-start
dtach -n "$dtachdir"/"$name" "$emacs" -nw --no-splash --eval "(setq server-name \"$name\")" -f server-start
fi
if [ ! -z "$waitp" ]; then
while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done
fi
and connect-emacs (intact)#!/bin/bash
# Usage: connect-emacs <name> <args>...
#
# Connects to the Emacs instance called NAME. Starts up the instance
# if it is not already running. The rest of the arguments are passed
# to emacsclient.
name="$1"
shift
if [ -z "$name" ]; then
echo "Usage: connect_emacs <name> <args>..." >&2
exit 1
fi
preload-emacs "$name" wait
/usr/local/bin/emacsclient -s "$name" "$@"
and I also have 'e' for x display client and 'et' for terminal client at hand, haha both shorter than 'vim'
~/bin/e:#!/bin/bash
connect-emacs editor $@ ~/bin/et:#!/bin/bash
connect-emacs editor -t $@ |
|