OS X下的Emacs Deamon模式设置

凌长恨
2023-12-01
由于Emacs插件配置越来越多,启动速度都快赶超IDE了。所以试验了下daemon模式,效果不错。除了第一次启动daemon比较慢,后面的基本上是秒启。

一、安装emacs
没安装Emacs的可以从[Emacs for Mac OS X]: [url]http://emacsformacosx.com/builds[/url]下载安装。

二、创建一个daemon应用
打开AppleScript编辑器,粘贴如下内容:

tell application "Terminal"
do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon >/dev/null 2>&1 &"
end tell

保存到/Applications目录下,名字为“Emacs Daemon”,[color=red]文件格式为“应用程序”[/color]。

三、创建一个client应用
打开AppleSciprt编辑器,粘贴如下内容:

tell application "Terminal"
try
set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'"
if frameVisible is not "t" then
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
end if
on error
do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
end try
end tell
tell application "Emacs" to activate

保存到/Applications目录下,名字为“Emacs Client”,[color=red]文件格式为“应用程序”[/color]。

配置完毕。启动的时候先启动Emacs Daemon应用。之后都是使用Emacs Client启动就可以了。
 类似资料: