Anxious Mo-Fo

An anxious m*********** from Seattle

Getting GNU Emacs to play nicely on Mac OS X

with 3 comments

… 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

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.

GNU Emacs

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.

Advertisements

Written by JPP

July 19, 2008 at 9:49 am

Posted in Emacs, Mac OS X

3 Responses

Subscribe to comments with RSS.

  1. If you don’t want to type in the long path to w/e emacs version you use make a Bash alias (or whatever shell you’re using).

    And also using MacPort to install Emacs.app is the best alternative to Aquamacs on the mac, install MacPorts and use sudo port install emacs-app

    Travis Jeffery

    July 20, 2008 at 5:36 pm

  2. Thanks, Travis. I might give it a try – it looks like it is based on Emacs.app, which also can be downloaded without MacPorts in a binary distribution.

    (I have an alias to that command; I wasn’t sure that UNIX geeks new to OS X would know right away which command to alias.)

    anxiousmofo

    July 20, 2008 at 6:40 pm

  3. “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.” Exact same opinion here. Thanks for the tip on non-antialiasing.

    Zhiming Wang

    June 15, 2014 at 11:19 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: