tags:

views:

799

answers:

4

I am using emacs in Ubuntu. How can I remap META to the ALT key?

+6  A: 

Usually Meta is mapped to the Alt key by default.

What is displayed in the echo area at the bottom of the Emacs window when you type Alt+X? If you see M-x then Alt is working as Meta.

Dave Webb
Actually it shows M-x even if you call execute-extended-command via some other binding (I personally bind it to C-; for fast access), so seeing M-x when you type Alt-x could also mean that Alt is mapped to something else than Meta, say Super, but Super-x is bound to execute-extended-command.
Jouni K. Seppänen
+3  A: 

Use xkeycaps to look at your keyboard mapping and swap the META and ALT modifiers, or just swap the entire keys. Because GNOME has some assumptions about which keys have META and ALT modifiers, it'll probably make your life easier to swap the keys entirely.

xkeycaps should be available as an ubuntu package.

shapr
+3  A: 

Way back when, it did seem that the META key was difficult to map to the ALT. At that time I had to use xmodmap, and these were the things I had to put in my .xmodmap file. Some variation of the following always worked (it depended on the system). My .xinitrc file would have xmodmap read in the file.

!! Note the `!` are comment characters.

!! suggested to make Emacs work under VNC
keysym Alt_L = Meta_L
keysym Alt_R = Meta_R

!! xmodmap -e 'keysym Alt_L = Meta_L' -e 'keysym Alt_R = Meta_R'
!!
!! some environments still can't handle alt key properly
!! add this:
!!
clear Mod1
add Mod1 = Meta_L Meta_R

!! or
!! xmodmap -e "clear Mod1" -e "add Mod1 = Meta_L Meta_R"
Trey Jackson
+1  A: 

If you run emacs in a gnome-terminal, the gnome-terminal may be capturing your alt key to open the gui menu (File, Edit, ...). You can change this behavior by selecting Edit >> Keyboard Shortcuts ..., and unchecking `Enable menu access keys ...'.

On my system, Ubuntu 9.04, this lets alt serve as meta for emacs.