0

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

slav3000
  • 1
  • 1
  • This question is tagged 'terminal-emacs', are you running 'emacs -nw' or the gui version? – rpluim Apr 18 '21 at 11:38
  • I'm using emacs -nw, not the gui version – slav3000 Apr 18 '21 at 14:04
  • What does setxkbmap -query say? What happens if you don't do anything with either setxkbmap or xmodmap to begin with? If I start xterm and then do xev and then press the left Alt key and x together, xev reports four independent events: KeyPress Alt_L, KeyPress x, KeyRelease x, KeyRelease Alt_L. Nevertheless, emacs -Q -nwsynthesizes aM-x` out of the same combination. So try without anything and edit your question with your findings. – NickD Apr 18 '21 at 19:56
  • 1
  • This sounds like an issue with your terminal, not with emacs. Does M-x work as expected in gui emacs? What terminal are you using? – Tyler Apr 20 '21 at 17:46
  • Yes actually it seems the problem comes from my terminal, I'm using xterm – slav3000 Apr 20 '21 at 19:51
  • What version of xterm are you running? I have XTerm(366). I start emacs -Q -nw in an xterm and Alt_L x is recognized as M-x. xmodmap -pm looks similar to yours (I don't have Alt_R in there) and so does setxkbmap -query. Can't think of anything else ATM - sorry. – NickD Apr 21 '21 at 05:14
  • I have Xterm(367), well thank you anyway ! – slav3000 Apr 21 '21 at 13:42

0 Answers0