[问题]有谁配置好了emacs 23的server client模式?
发表于 : 2008-02-18 11:49
具体说说怎么做的,谢谢。
emacs很适合我,可是启动太慢,看了些文档还是不知道怎么让他自动启动server。
emacs很适合我,可是启动太慢,看了些文档还是不知道怎么让他自动启动server。
TIPS & TRICKS
-------------
I think the best way to use the new Emacs is to have it running inside
a disconnected GNU screen session, and always use emacsclient for
normal work. One advantage of this is that not a single keystroke of
your work will be lost if the display device that you are using
crashes, or the network connection times out, or whatever. (I had an
extremely unstable X server for some time while I was developing these
patches, and running Emacs this way has saved me a number of M-x
recover-session invocations.)
I use the following two bash scripts to handle my Emacs sessions:
-------------------------------------------------------connect-emacs--
#!/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/bin/emacsclient.emacs-multi-tty -s "$name" "$@"
----------------------------------------------------------------------
-------------------------------------------------------preload-emacs--
#!/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"
screendir="/var/run/screen/S-$USER"
serverdir="/tmp/emacs$UID"
emacs=/usr/bin/emacs-multi-tty # 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 "$serverdir/$name" ]; then
# Delete leftover socket (for the wait option)
rm "$serverdir/$name"
fi
screen -dmS "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" -f server-start
fi
if [ ! -z "$waitp" ]; then
while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done
fi
----------------------------------------------------------------------
I have the following in my profile to have two instances automatically
preloaded for editing and email:
preload-emacs editor
preload-emacs gnus
It is useful to set up short aliases for connect-emacs. I use the
following:
alias edit="connect-emacs editor"
alias e=edit
alias et="connect-emacs editor -t"
alias gnus="connect-emacs gnus"