Emacs for Mac OS X

Emacsen

There are a few ‘native’ versions of Emacs for Mac OS X: by ‘native’, I mean they have an Aqua interface, and don’t require an X11 server. Here are the full names of the ones that I know of, so you know what to google for if you’re ever that interested :).

  • Emacs on Aqua. Works with Panther, but seems quite unstable.
  • Carbon Emacs. Sources and binaries are available on that page, although I don’t know if the binaries available there work with Panther. However, recent binaries (built from the CVS repository) which do work with Panther can also be obtained from Mindlube’s Emacs page. This is the Emacs version I currently use with Panther.
  • Enhanced Carbon Emacs. Same as the above, but has a couple more packages, in particular ones which support LaTeX/AucTeX/etc. Binaries only, and the author has now updated Enhanced Carbon Emacs to work with Panther. Recommended.
  • Emacs 21 for Mac OS X — Source only. Ovidiu Predescu has put together a binary package of it. Ovidiu’s page also has some nice key bindings you can add to your ~/.emacs file to get Cmd-X/C/V, Cmd-S, Cmd-L etc. working, if you’re a veteran classic MacOS user.
  • XEmacs 19.14 for Macintosh (and also XEmacs 21.5.9 for Macintosh, which is considered alpha right now). I haven’t tested to see whether this works with Panther.

I’m fairly sure that all of them are based on GNU Emacs (except the XEmacs port, obviously).

The version I used in Jaguar is Enhanced Carbon Emacs: it’s been very stable and comes with lots of useful packages. Mind you, I haven’t used it that much—I use vim for most of my Unix editing—but Emacs works when I need it. Now Enhanced Carbon Emacs is available for Panther, but I haven’t tried it yet since I don’t use Emacs too often.

When you install any of those Emacs packages, it’ll stick an Emacs application in the /Applications directory like any other Mac app. If you’re using it from the terminal a lot, here’s a shell script I wrote which will open the GUI version of Emacs (and leave the console window “frozen” while the GUI is running, just like a normal X11 app):

#!/bin/sh

if [ -x '/Applications/Emacs.app/Contents/MacOS/Emacs' ]; then
  exec /Applications/Emacs.app/Contents/MacOS/Emacs "$@"
else
  exec /usr/bin/emacs "$@"
fi

Emacs in text fields?

If you haven’t found out by accident yet, you can actually press C-a and C-e inside a text field in Cocoa application to go to the beginning and end of the line. It turns out that key bindings for Cocoa applications are completely customisable, which is just way cool. The default key bindings are in a property list file at /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict, and you can override those key bindings with a file in ~/Library/KeyBindings/DefaultKeyBinding.dict. You’ll never look at the humble TextEdit application in the same way again.

If you’re an Emacs guy, I highly recommend getting TextExtras , which allows you to do things like pipe the contents of the text field through filters (run your word processing document through sed -e s/foo/bar/, sweet), and also adds the can’t-live-without dynamic abbreviation and abbreviations features.

See gnufoo’s Mac OS X page for a slightly more in-depth look at how to bind keys to Emacs commands. After that, you can grab my DefaultKeyBinding.dict file, which has things like M-/ bound to dynamic abbreviation already.

blog comments powered by Disqus