設定内容
Emacs daemonをログイン時に起動しておいてemacsclientを使用する。
Emacs daemonが落ちていたら再起動するようにする。
設定方法
Automatorで以下のようにAppleScriptを実行できるようにして, EmacsClientという名前で/Applicationsに保存する[1]。
on run {input, parameters}
try
tell application "Terminal"
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -create-frame --alternate-editor=''"
end tell
on error
tell application "Terminal"
do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -create-frame --alternate-editor=''"
end tell
end try
return input
end run
以下のファイルを~/Library/LaunchAgents/gnu.emacs.daemon.plistに保存して, launchctl load -w ~/Library/LaunchAgents/gnu.emacs.daemon.plist
を端末から実行する[2]。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>gnu.emacs.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Emacs.app/Contents/MacOS/Emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Gnu Emacs Daemon</string>
</dict>
</plist>
参考ページ
[1] https://gist.github.com/redinger/1394910
[2] https://www.emacswiki.org/emacs/EmacsAsDaemon