I am using emacs in Ubuntu. How can I remap META to the ALT key?
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
.
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.
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"
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.