MacOS – changing the meta key in emacs

emacskeyboardmacosterminal

I am running emacs 24.3 through the terminal on OS X 10.8.4. I would like to modify the meta-key which is currently set to be the ESC key. I have successfully changed the meta-key from ESC to option/alt however I am interested in remapping the meta-key to be the left-shift key. As I never use the left-shift key, I wouldn't mind remapping it permanently for all applications on my machine.

  1. How can I change the meta-key in emacs running from the terminal to any other key?
  2. Specifically, I would like to change the meta-key to left-shift as this would be really close to where my fingers are usually placed.
  3. Can this be configured through emacs via emacs-lisp? Or, must this be configured through OS X settings such as how I changed the caps-lock key?

All help is greatly appreciated!

EDIT: How can I do this both on my mac and when I connect remotely?

Best Answer

Meta key problems with emacs seem to be very common, especially on OSX where alt/option is used to input special characters by default.

If you are using AquamacsEmacs[Aquamacs Homepage] or CarbonEmacsPackage, you may be able to set the modifier keys within your .emacs or other preferences file.

Specifically to map shift to meta, I'd try this (Note: this is untested):

(setq mac-shift-modifier 'meta)

If that doesn't work, there may not be an easy way to remap shift in this fashion. You may need to look into the define-key function in emacs lisp.

Otherwise, if you're using emacs via the terminal, from homebrew, or some port of xemacs with XQuartz, you might want to look into using xmodmap