[问题]有谁配置好了emacs 23的server client模式?

Vim、Emacs配置和使用
回复
头像
zhuqin_83
帖子: 10606
注册时间: 2006-05-13 4:02
联系:

[问题]有谁配置好了emacs 23的server client模式?

#1

帖子 zhuqin_83 » 2008-02-18 11:49

具体说说怎么做的,谢谢。
emacs很适合我,可是启动太慢,看了些文档还是不知道怎么让他自动启动server。
HP Pavilion DV6-2064CA: AMD Turion II Ultra Dual-Core Mobile M640, HD4650, 2GBx2 DDR2-800, Seagate 500GB 7200RPM SATA, BD-ROM
DELL UltraSharp 2209WA
Arch64, Testing repo
zhangsong023
帖子: 768
注册时间: 2006-09-20 19:56

#2

帖子 zhangsong023 » 2008-02-19 13:05

在配置文件(比如.emacs.el)中加入(server-start)就自动启动server模式了。
头像
zhuqin_83
帖子: 10606
注册时间: 2006-05-13 4:02
联系:

#3

帖子 zhuqin_83 » 2008-02-19 13:44

这个我自然知道,我想问如何启动机器时就执行,并且和screen集成。
http://www.emacswiki.org/cgi-bin/wiki/EmacsClient
这个看了比较头大,不知道怎么弄。
HP Pavilion DV6-2064CA: AMD Turion II Ultra Dual-Core Mobile M640, HD4650, 2GBx2 DDR2-800, Seagate 500GB 7200RPM SATA, BD-ROM
DELL UltraSharp 2209WA
Arch64, Testing repo
zhangsong023
帖子: 768
注册时间: 2006-09-20 19:56

#4

帖子 zhangsong023 » 2008-02-19 14:07

读一下multi-tty的readme啊。
以下都是从那儿摘过来的:
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"
头像
zhuqin_83
帖子: 10606
注册时间: 2006-05-13 4:02
联系:

#5

帖子 zhuqin_83 » 2008-02-19 14:18

是不是把这两个脚本放到/usr/bin,然后在/etc/profile里添加
preload-emacs editor
preload-emacs gnus
再弄几个alias就可以了呢?
HP Pavilion DV6-2064CA: AMD Turion II Ultra Dual-Core Mobile M640, HD4650, 2GBx2 DDR2-800, Seagate 500GB 7200RPM SATA, BD-ROM
DELL UltraSharp 2209WA
Arch64, Testing repo
zhangsong023
帖子: 768
注册时间: 2006-09-20 19:56

#6

帖子 zhangsong023 » 2008-02-19 17:25

差不多,我喜欢放家目录里面,写全路径就可以了。
脚本里有的命令的路径要按实际改一下,它都做了详细说明。
回复