changing emacs’ meta key

I’ve been using Carbon Emacs for several months now on my MacBook Pro, having gotten fed up with Textmate’s awkwardness. The learning curve has been steep at times, but definitely worth it.

Now that our team has decided to develop on a linux VM (via Parallels) on our macbooks, so we can run against a local Oracle db, I get to reap one of the benefits of using a cross-platform editor. Were I still using Textmate, I’d either have to switch editors to one that runs on linux, or add some magic to edit files “remotely” over an ssh connection to the linux instance, at the expense of a performance loss.

Switching isn’t without its gotchas though. The first issue was that my .emacs file depended on some libraries that are bundled with Carbon Emacs. By comparing the *Messages* right after starting emacs in both versions, it wasn’t too hard to add a couple more search paths to make sure everything I needed was found and loaded.

The real problem was that I was used to using the Apple/Command key as the Meta key, but in the linux X11 environment in Parallels, Meta was mapped to the Option key, while the Command key was apparently being picked up by emacs as the ’super’ key, based on running things like ‘C-h k S-j’ etc.

Based on the docs, adding these lines to my emacs file should have fixed it:

(setq x-super-keysym 'meta)
(setq x-meta-keysym 'super)

This made Command-d and Command-delete register as M-d and M-delete, as expected, but Command-x and Command-v got interpreted as C-x and C-v. ?!? Those variables were just introduced in Emacs 22, and from what I could tell, they didn’t quite work as expected. Granted, running linux x11 inside parallels on a macbook is probably an edge case the authors didn’t opportunity to test properly, so I can’t really complain much.

In the end, I wound up ditching emacs on the linux vm, and instead I’m using good old Carbon Emacs and tramp to edit files on the linux partition over ssh/scp. Gotta quit tinkering and get some real work done.

Leave a Reply