简体   繁体   中英

Use Alt key as Meta in emacs

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 "AX" 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!

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)

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

Entering this command in a shell (even Mx 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM