views:

622

answers:

3

Problem: EmacsW32 is a version of Emacs that allows the user to make Emacs treat the "Windows" key as the "Meta" key (instead of treating the Alt key as the "Meta" key). Although this works as advertised, the question is what happens when you want to create an Emacs keybinding for the "Alt" key?

Question: Is there a way in this case to allow Emacs to capture and create keybindings to the "Alt" key also, even though it now considers "Windows" key to be the new Meta?

+1  A: 

You can either bind both the Windows and the Alt key to Meta, or you can assign the Alt key to a different change key. Emacs provides these possible bindings:

Shift
Control
Meta
Hyper
Super

You will have to look at your system's documentation for how to bind the physical keys to these (e.g. man xmodmap for X windows).

Svante
+3  A: 

To figure out if Emacs is recognizing your Alt key at all: type C-h c, then some key combination that starts with Alt, e.g. Alt-f.
If it says "M-f runs the command forward-word" (for example), then Emacs thinks of your Alt key as a Meta key too, and anything you bind to Meta will work with both the Windows key and the Alt key, so there is no way to make the Alt key work differently from the Windows key.
If it says "Hyper f is undefined" or "Super f is undefined" (for example) then Emacs recognizes your Alt key as either Hyper or Super respectively, and you can bind commands to keybindings starting with Hyper or Super, and those will work with your Alt key.
If it doesn't react at all, then it means it's not recognizing the Alt key as anything, and there is nothing you can do from within Emacs: Emacs doesn't even get the key. In this case, as the other answer said, you should look up the equivalent of xmodmap for Windows -- it's something to do with the registry; the GNU Emacs FAQ for Windows's section on How do I swap CapsLock and Control? has some relevant details about this ("Scancode); also see this page.

ShreevatsaR
+1  A: 

You might want to look at the thread on Super and Hyper keys in EmacsW32.

I haven't rebound my Meta key (still on Alt - I use it most often) but Super and Hyper are bindable to the various windows- and app- keys.

Michael Paulukonis