Warning: I only use terminal emacs so I have no idea how well this will work otherwise.
Here's what I use to get the very latest emacs goodies:
sudo brew install emacs --cocoa --use-git-head --HEAD
Here is what my file looks like:
<?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>/usr/local/Cellar/emacs/HEAD/Emacs.app/Contents/MacOS/Emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Gnu Emacs Daemon</string>
<key>UserName</key>
<string>kelly</string>
</dict>
</plist>
launchctl load gnu.emacs.daemon
launchctl start gnu.emacs.daemon
Instead of opening a file with emacs <filename>
instead use emacsclient -nw <filename>
.
I created a handy alias in my .bashrc
file.
alias e="emacsclient -nw"
From within emacs, use the save-buffers-kill-emacs
command.
Outside of emacs:
emacsclient -e '(client-save-kill-emacs)'
Setting up the daemon has a several advantages.
- Files load much faster.
- You can share buffers among different
emacsclient
instances. - If you exit all the
emacsclient
instances and come back later, your buffers are all still open. When you access a buffer the cursor will be at the exact spot you left off previously.
The server does occasionally crash, but that is probably because I am using the bleeding edge version. It hasn't caused me to lose anything thanks to auto-saving and file recovery so go for it.