Warning: I only use terminal emacs so I have no idea how well this will work otherwise.
Install emacs 23 or later.
Here is what I use to get the very latest emacs goodies:
Some people have had trouble with the
--cocoa flag so you may find
it convenient to omit that if you do not need the Cocoa version. Also
if you do not want the bleeding edge version, then omit the
--use-git-head --HEAD options.
Create a plist file and move it to ~/Library/LaunchAgents
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>
Update the path the emacs and change the username to your OS X user name.
Start the daemon
Edit files with emacsclient instead of emacs
Instead of opening a file with
emacs <filename> instead use
emacsclient -nw <filename>.
I created a handy alias in my
Stopping the daemon
From within emacs, use the
Outside of emacs:
Setting up the daemon has a several advantages.
- Files load much faster.
- You can share buffers among different
- If you exit all the
emacsclientinstances 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.