I would like to set my Alt_L to trigger a meta key in emacs.
I've tried using xmodmap to set Alt_L as Mod1, Mod2, Mod3. But in emacs, when i try to type Alt_L + x (expecting M-x) it only prints "x".
I start X server with : setxkbmap -model pc105 -layout us,fr -option grp:alt_shift_toggle -option caps:none
When I print the modifiers with xmodmap -pm
I get :
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock
control Control_L (0x25), Control_L (0x42), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
I feel the problem comes from emacs, not from X keyboard config.
How emacs handles those modifiers ?
EDIT: setxkbmap -query
ouputs when I start X:
rules: evdev
model: pc105
layout: us,fr
options: ctrl:nocaps,grp:alt_shift_toggle
Using xev
when I type Alt_L then x, then release x and release Alt_L I get:
KeyPress event, serial 34, synthetic NO, window 0xc00001,
root 0x1d9, subw 0x0, time 5433348, (-2,510), root:(640,512),
state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 34, synthetic NO, window 0xc00001,
root 0x1d9, subw 0x0, time 5438940, (-2,510), root:(640,512),
state 0x8, keycode 53 (keysym 0x78, x), same_screen YES,
XLookupString gives 1 bytes: (78) "x"
XmbLookupString gives 1 bytes: (78) "x"
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0xc00001,
root 0x1d9, subw 0x0, time 5439004, (-2,510), root:(640,512),
state 0x8, keycode 53 (keysym 0x78, x), same_screen YES,
XLookupString gives 1 bytes: (78) "x"
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0xc00001,
root 0x1d9, subw 0x0, time 5442460, (-2,510), root:(640,512),
state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
setxkbmap -query
say? What happens if you don't do anything with eithersetxkbmap
orxmodmap
to begin with? If I startxterm
and then doxev
and then press the leftAlt
key andx
together,xev
reports four independent events: KeyPress Alt_L, KeyPress x, KeyRelease x, KeyRelease Alt_L. Nevertheless, emacs -Q -nwsynthesizes a
M-x` out of the same combination. So try without anything and edit your question with your findings. – NickD Apr 18 '21 at 19:56xterm
are you running? I haveXTerm(366)
. I startemacs -Q -nw
in an xterm andAlt_L x
is recognized asM-x
.xmodmap -pm
looks similar to yours (I don't haveAlt_R
in there) and so doessetxkbmap -query
. Can't think of anything else ATM - sorry. – NickD Apr 21 '21 at 05:14