Emacs server 新启动方式 (仅在emacs daemon未启动时才启动daemon)

旧的启动方式是将 emacs --daemon 放在 .xinitrc 或者 .profile 或者 rc.lua 中 让它随系统一起启动

这种方式会减慢开机速度, 随着配置越来越多, 有时候开机并不用 emacs 导致开机边的很慢, 得不偿失

尝试了 emacswiki 上提到的 (server-start) 方式. 但是好像不成功. 每次都会尝试用 emacs --daemon 启动emacs

导致每次启动都很慢, 还不如不用.

后来在 so 上查到, 这种方式在 emacs 23 之后基本上就已经被废弃掉了. 新的启动方式如下.

配置你的 .zshrc 或者 .bashrc

export ALTERNATE_EDITOR=""

Ok 搞定... 就这么简单.

之后你再用 emacsclient -c 命令行 或者 emacsclient -t 图形 方式启动 emacs 如果 emacs --daemon 没有启动
系统会自动的尝试使用 emacs --daemon 命令来启动. 否则直接打开.

这样做还有一个好处, 直接 emacs 是不会启动 daemon 的, 其实也不算什么好处 哈哈.

ps
加上另外两个实用的配置
让 emacsclient -c 成为默认编辑器, 方便编辑 git svn 提交
export EDITOR='emacsclient -c'
绑定 e 到 emacsclient -t 直接在命令行内打开某个文件编辑
alias e='emacsclient -t'

posted @ 2012-11-03 20:26  LemonLi  阅读(1898)  评论(0编辑  收藏  举报