Getting GNU Emacs to play nicely on Mac OS X
… Is, it turns out, much easier than it was the last time I tried.
If your goal is to have a version of Emacs which acts as much like an OS X app as it possibly can, then you should download Aquamacs Emacs. If your goal is to have an Emacs which acts like Emacs, but plays nicely with OS X – files can be dragged and dropped onto its Dock icon and onto its windows, text can be copied and pasted easily between Emacs and other OS X applications – then it’s not terribly hard to get vanilla GNU Emacs to do just that.
Aquamacs Emacs has nice pretty toolbar icons, pretty Safari-like tabs, and (by default, but this can be turned off easily) opens each buffer in its own window. You can use Mac keyboard shortcuts, e.g., Command-C to copy and Command-V to paste.
I use Emacs on multiple platforms. GNU Emacs 22.2.1 and Aquamacs Emacs 1.4 contain different versions of different packages (e.g., GNU Emacs opens XML files using sgml-mode.el; Aquamacs opens XML files using nxml-mode.el). That can make it difficult to share a single ~/.emacs file between different platforms, or at least it requires that you perform the same customization in two different ways (e.g., modifying nxml-child-indent on Aquamacs, and sgml-basic-offset on GNU Emacs). Aquamacs also does some unexpected things which I never did get around to disabling: for example, help windows open in new frames.
Installing GNU Emacs is a wee bit more difficult than installing Aquamacs Emacs. These steps assume that you know how to install software from source on a UNIX-like OS. GNU Emacs 22.2.1 compiles from source just fine on Mac OS 10.5.4 Intel, and may work on other Mac platforms.
First, install the XCode Developer Tools. Next, download and extract the GNU Emacs source. In a UNIX shell, navigate to the directory you extracted the source into. Run ./configure. These are the options I used:
./configure --prefix=/Applications/Emacs.app/Contents/Resources --exec-prefix=/Applications/Emacs.app/Contents/MacOS --enable-carbon-app
The –enable-carbon-app option is the one you need to enable if you want Emacs to have a dock icon and allow drag-and-drop and clipboard interaction with other apps. The other two options, the –prefix and –exec-prefix, are optional, but if you use them, everything you need to run Emacs will be placed into the Emacs.app bundle, and the next time you want to install Emacs, you just need to copy that Emacs.app bundle into the /Applications folder. Next, run make and make install, and you’re done.
You also have the option, although I didn’t try it, of compiling Emacs so that it runs under X11. I spent way too long using XEmacs under X11, with hinky clipboard interaction with Aqua apps, with ugly fonts, with no drag and drop between the Finder and XEmacs’ windows, and I’m glad I don’t have to do that anymore.
Using non-antialiased Monaco
Most Mac text editors – XCode, BBEdit/TextWrangler, TextMate – are configured by default to use non-antialiased Monaco. In my humble opinion, this is much more legible than antialiased Monaco or any other font I’ve tried on OS X. Both Emacs and Aquamacs enable antialiasing by default. To disable it, add a line like this to your ~/.emacs file*:
(setq mac-allow-anti-aliasing nil)
Many faces use bold or italic, or (on Aquamacs Emacs, especially) variable-width fonts like Lucida Grande, which look terrible with antialiasing disabled. The next step is to use customize-face to modify each of these faces so that they are not bold or italic, and so that they use Monaco. You can get to customize-face by typing M-x customize-face, or by clicking on Options in the menu bar, then clicking Customize Emacs > Specific Face…
Opening a file in a running instance of Emacs from a UNIX shell
You don’t need to use
gnuserv Emacs server and gnuclient emacsclient in order to open a file in a running instance of Emacs, in either Aquamacs or GNU Emacs – but that option is available. Instead, run one of these commands:
open -a /Applications/Emacs.app /path/to/file
open -a /Applications/Aquamacs\ Emacs.app /path/to/file
This shorter variant may also work:
open -a Emacs /path/to/file
open -a Aquamacs\ Emacs /path/to/file
* Aquamacs Emacs reads your ~/.emacs file, and it also reads its own customization file, ~/Library/Preferences/Aquamacs Emacs/Preferences.el. You can also customize the variable, by typing M-x customize-variable RETURN mac-allow-anti-aliasing.