November 17, 2003

Getting XEmacs working with Panther on the AlBook

None of this is rocket science, but since I didn’t see a page with all this information in once place I figure it can’t hurt. I assume they’re mostly applicable to (Power e i)Macs as well, but I can’t say for sure.

I realize there are a number of native emacs implemenations out there. And I installed one. But I have a couple of reasons for using the XEmacs under X implementation. One reason: I've been using XEmacs for six or seven years and while I don't do a lot of customizations there are a few. A second: a native implementation won't read my SSH agent environment variables so I can use CVS seamlessly. Maybe there are other ways to get around this, but you can go somewhere else to find them.

Okay, onto business. First, install Fink. The installation instructions are very good (as is the other documentation I've read) and I've been content to use fink to compile everything rather than apt-get and company.

If your PowerBook was shipped with Panther you probably need to go grab Apple's X11 implementation and install it. While you're at it you'll need to go into /Applications/Installers/Developer Tools and install the X11 SDK. You might as well install other dev tools while you're there, these things ship with big enough hard drives...

Now do a:

fink install xemacs

It'll ask you to install a whole bunch of supporting libraries, just say yes. Then go grab a sandwich and a few chapters of your favorite book -- short chapters are okay. Hopefully it will compile cleanly. Once it does run:

fink install xemacs-sumo-pkg

This brings in all the xemacs packages -- why not?

When you startup XEmacs you'll eventually notice that there's no Alt/Meta key. (I don't know the difference between these, nor do I care.) Even though the 'Option' key also has a small 'Alt' label it won't work. Instead you'll have to use 'Esc'. That blows. So here's how to change your key mapping so that the Command (a.k.a, 'Open Apple') key is used as the meta key.

Open up the file ~/.Xmodmap and enter the following:

! Make 'Option' key be Meta and Command be Alt.
! See http://mail.gnu.org/archive/html/help-gnu-emacs/2003-05/msg00389.html
clear mod4
keycode 66 = Meta_L
keycode 63 = Mode_switch
add mod4 = Meta_L

Before shutting down X11 to reload this you'll need to modify a couple of options. Open up the X11 preferences ('X11 | Preferences...') and pick the 'Input' tab. (Are they called 'tabs' in Aqua? Whatever.) Uncheck the 'Follow system keyboard layout' and 'Enable key equivalents under X11'. Yes, this means that 'Command-,' won't open up your preferences window anymore, and you can't use 'Command-Q' to exit X. Oh well. You probably won't be shutting it down often anyway.

Now shutdown X and restart it, then fire up XEmacs. You should be able to use both Command keys as Meta/Alt, even with chords like Command-Q. Have fun.

There's probably something I've missed, an easier way to do something, etc. Let me know, I'm just learning...

UPDATE: fixed comments in Xmodmap thanks to a comment.

Next: Partial classes and code generation
Previous: Setting up the Mac and cleaning out the cruft