August 16, 2006

Emacs tips: Cross-platform Emacs

Author: Nathan Willis

As much as we love Linux and other Unix-like operating systems, we are sometimes forced to work on others -- Windows, perhaps, or Mac OS X. Fortunately, the world's best editor is available on all of them -- though as is sometimes the case with free software, there are several competing versions, with their own pros and cons. Let's take a look at the options, and decide how to pick the best non-Unix Emacs for our daily work routine.

Windows

The standard GNU Emacs builds on all recent flavors of Windows -- NT, XP, 2000, ME, even 98 and 95. You can download Windows binaries from the official GNU project Web site. Before you even begin to download it, you will notice that this version of Emacs is very Unix-like: the package is a .tar.gz compressed archive, not a .zip file like so many other Windows applications.

Most compression utilities for Windows can handle both tar and gz, so it is nothing to worry about. But when you have unpacked the archive, don't expect to find a GUI InstallShield wizard -- the un-tarred package is ready to run. You launch Emacs by executing runemacs.exe, to which there should be a shortcut in the top level of the archive. If there isn't, the original runemacs.exe is in the bin folder. For those who consider this process lacking in glamour, recent Windows builds have added another binary named addpm.exe that functions more like a typical Win32 installer, including niceties such as adding Start menu shortcuts.

Of course, any user who craves Windows-like behavior when using Emacs will have more to contend with than just the installer. When you are working on a Unix-like system day-in and day-out, the Emacs key bindings become second nature. But when you have to switch back and forth between the Unix-like Emacs and typical Windows apps, the differences can begin to wear on you.

The official Emacs FAQ contains a section on modifying Emacs so that it behaves more like a traditional Windows app. Some behavioral changes -- like automatically deleting selected text when you type over it -- are already built in to Emacs, though they are disabled by default. Others, like remapping Windows key bindings to Emacs commands like cut-and-paste, require you to download an add-on .el (ELisp) file to change your preferences.

I used plain old vanilla Emacs on Windows for years with no complaints whatsoever. But if you are seriously interested in the Windows-like modification of Emacs, there is another alternative to consider: Emacs W32.

Emacs W32 is a Windows-centric distribution of Emacs. At the Emacs W32 site, you can download the full Emacs application, all of the Windows-like modifications, and a suite of helper apps all in one fell swoop, and install them with a pretty installer. The makers of Emacs W32 put a lot of work into bundling Emacs and the assorted add-ons -- you can download a variety of packages from their site, including their own patched build of Emacs and a package containing just the add-ons, for those who already have Emacs running.

Mac OS X

Because OS X is a member of the Unix family tree, Emacs there enjoys more popularity than it does on Windows. The GNU project does not regularly release separate Emacs builds specific to OS X as it does for Windows, perhaps because OS X can implement the X11 toolkits and API. Nevertheless, there are a number of convenient Emacs ".app" binaries available for easy installation. With such convenience comes the potential for confusion, though -- there are multiple packages out to integrate Emacs with OS X.

The Big Two at this time are Carbon Emacs and Aquamacs Emacs. Carbon Emacs is a patched version of the up-to-date Emacs code from the GNU project's CVS, polished up with a series of add-on packages for niceties like OS X key bindings. This is the Emacs variant given the semi-official endorsement of inclusion in Apple's online OS X software repository. For many users, Apple's directory is the first place the turn when looking for software, so Carbon Emacs is the Emacs they will use.

Aquamacs Emacs is an independent OS X integration effort; it has roughly the same goals as Carbon Emacs and is more or less in sync with the same CVS version. The real difference between the two is that Aquamacs Emacs is a little more "integrated" by default.

For example, both allow you to navigate around the page using the keyboard's arrow keys, but Aquamacs Emacs moves you up and down one display line at a time (whether the line wraps around on the screen or not), while Carbon Emacs strictly obeys the file's line breaks. Strictly obeying the line breaks even on wrap-around is Emacs' default behavior, but it is not always the most convenient for editing.

Another noticeable difference is that by default Aquamacs Emacs opens new files in new top-level windows, whereas Carbon Emacs opens them in a new buffer in the existing window. Here again Carbon Emacs is sticking to the traditional Emacs behavior. Which is preferable depends a lot on what type of work you are doing.

I am personally a little more partial to Aquamacs Emacs; your mileage may vary. Just how integrated you want your editor to be is a personal choice. But all of the differences between Carbon and Aquamacs Emacs are a matter of app-level preferences; you can alter either of them to your heart's delight. And in the end, isn't that the beauty of Emacs, on any platform?

Click Here!