8
votes

Somehow the emacs I'm using doesn't treat Alt as Meta. It only uses ESC for it. If I press Alt+x it will tell me "A-X" undefined. I tried to figure out how to map it to meta but got no luck on the web because in most of results from my search people take Alt as Meta by default. I guess something like this should work:

global-set-key Alt(?) 'meta

but I'm not sure how to represent Alt in lisp.. any help? Thanks!

3
Which operating system are you using? - Lindydancer
@koopajah I took a short look and didn't find my solution. This looks like a very simple issue doesn't it? I just need to know how to represent Alt key in lisp?? :( - user1861088
@Lindydancer Linux via xterm on a windows machine - user1861088
Ironically I was looking for the opossite: how to enable the ALT key in an English keyboard? - jgomo3

3 Answers

7
votes

Most solutions will tell you to change keymap at the X11 level. The wiki suffers from the problem of too much information. If you just want a solution that works only at the emacs level (quite useful for VNC/remote desktop), then add the below line to your emacs init file

;; Map Alt key to Meta
(setq x-alt-keysym 'meta)
0
votes

I had the same problem and by putting this in ~/.emacs helped me.

(set-keyboard-coding-system nil)

Refer to this, if you need more help http://www.emacswiki.org/emacs/MetaKeyProblems#toc15

0
votes

Entering this command in a shell (even M-x shell) works for me.

xmodmap -e "clear mod4"

This works when the problem is that the output of xmodmap includes a line showing that Meta_L is set to mod4:

mod4        Meta_L (0x73)

Emacs thinks your keyboard has a Meta key, so it's not interpreting Alt as Meta. The above command tells X that you don't have a Meta key, so Emacs will interpret Alt the way that we're used to.

I learned this from https://www.emacswiki.org/emacs/MetaKeyProblems.