Theresa O’Connor

Using Emacs under Terminal.app

On my work laptop, a Powerbook, I use a Carbon build of Emacs’ CVS HEAD. I use the Command key as Meta, since "the key to the left of space is Meta" is utterly ingrained at the muscular level. But when I SSH to a remote host in a Terminal window, the Command key is taken by Terminal.app, and the Option key acts as Meta. This wouldn’t be a problem if I didn’t use fill-paragraph (bound on M-q) so often. Since Command-Q quits Terminal, I lose all of my SSH sessions if I accidentally use the Command key instead of the Option key. Evil! Just the same, trying to copy some text with M-w results in the terminal window closing. Ugh.

Another problematic key is M-p, which is often bound (in the minibuffer, in shell buffers, etc.) to "give me the previous element in my input history." Command-P brings up the print dialog box, which is pretty much never what I want to happen.

Here’s a shell command which overrides those key bindings, so I don’t do so much damage:

defaults write NSGlobalDomain NSUserKeyEquivalents \
   '{"Quit Terminal" = "@$Q"; "Close" = "@$W"; "Print..." = "@~P";}'

This places the Quit command on Command-Shift-Q, the Close command on Command-Shift-W, and the Print command on Command-Option-P. You’ll have to quit and re-launch Terminal.app for these to take effect.