5

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?

  • 1
    For the purposes of seeing if we can provide a detailed solution, what key on the keyboard do you wish to map to be meta and what do you propose to do about the functionality that key would normally provide? My guess is you'd swap esc and this key, but I'd rather not guess if you have a preference in mind. – bmike Jun 13 '13 at 13:30
  • I would like the left-shift key which is right under caps-lock on my machine to function as the meta-key. Swapping them would be fine, but if you could tell me how to go about that process, that would be even better as I could experiment to see what I like best :) – CodeKingPlusPlus Jun 13 '13 at 19:05
  • 1
    Remapping keys (especially special keys) on a per-app basis isn't something the OS has a framework to provide, so you'll need a low level hack to accomplish the ideal choice. Would you be amenable to having the left shift key permanently reassigned? You might even be able to automate that, but I'd have to check on the ukulele users or download the latest version of that app to experiment. http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ukelele – bmike Jun 13 '13 at 19:22
  • 1
    I would like the left shift key permanently reassigned. That sounds awesome! I'll look into it as well. – CodeKingPlusPlus Jun 13 '13 at 19:43
  • This post has a lot of information about keyboard layouts. – Chauncey Garrett Jun 18 '13 at 21:35
  • Do you want a solution that works when you are logged into a remote machine, e.g. via SSH, or is it OK if the solution only works for emacs running on your Mac? – Old Pro Jun 20 '13 at 05:07
  • Both would be ideal. – CodeKingPlusPlus Jun 20 '13 at 13:26
  • If you are trying to do this when you are logging in via a terminal window, Emacs is not the place you need to do it. You will need to configure your terminal emulator. In a terminal, Emacs does not get the raw keystrokes, it only gets the characters passed through the terminal. In particular, Emacs can't tell the difference between left shift or right shift, it just knows it got a capital A instead of a lowercase A. – Alan Shutko Oct 16 '13 at 02:19

2 Answers2

2

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

TrinitronX
  • 1,242
  • 12
  • 23
0

What about using a macro/hotkey program like Keyboard Maestro? (I have no affiliation with the program)

jimtut
  • 923