4

I'm running emacs 26.1 on a Centos 6.9 machine displaying via TightVNC server to a client running on my Mac OS X 10.14.2. To make things tricky, I'm also using Dvorak keyboard layout.

When I run emacs on my Mac, all works great. My Mac keyboard is an Apple Magic Keyboard with Numeric Keypad (Wireless, Rechargable) (US English) - Silver. If I press the option on either left or right side, it works as desired and generates meta in Emacs. If I press the command on either left or right side, it also works as desired and also generates meta in Emacs. I believe this is accomplished with the following (which doesn't fix my issue on Linux):

  (setq mac-option-modifier  'meta)
  (setq mac-command-modifier 'meta)

Now I'm trying to connect from my Mac via TigerVNC to my Linux machine which also has Emacs running. On that Centos 6.9 machine I had to disable the Dvorok keyboard layout preference as it was scrambling the input from the Mac keyboard, I think performing the transformation twice, once on my Mac and a second time on the Linux box.

However, the modifier keys are not working as desired. Here is what I get when trying to generate a M-x various ways:

  • left-option-x => Incorrect:
  • left-command-x => Correct: M-x
  • right-option-x => Incorrect:
  • right-command-x => Incorrect: s-x

I ran xmodmap -pm:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  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 ran xev and see the following:

left-option:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19839468, (104,80), root:(106,131),
    state 0x0, keycode 203 (keysym 0xff7e, Mode_switch), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 38, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 19839468, state PropertyNewValue

PropertyNotify event, serial 38, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 19839468, state PropertyNewValue

left-command:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19937256, (103,75), root:(105,126),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

right-option:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 19987161, (132,152), root:(134,203),
    state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: (1b) ""
    XmbLookupString gives 1 bytes: (1b) ""
    XFilterEvent returns: False

right-command:

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20026188, (93,166), root:(95,217),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Therefore, I tried the following with xmodmap:

! Map the right Macintosh Command key to Meta:
remove mod4 = Super_L
add mod1 = Super_L

! Map the left Macintosh Option key to Meta:
remove mod5 = Mode_switch
add mod1 = Mode_switch

! Map the right Macintosh Option key to Meta:
remove mod5 = ISO_Level3_Shift
add mod1 = ISO_Level3_Shift

Resulting in this status via xmodmap -pm:

xmodmap:  up to 7 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  ISO_Level3_Shift (0x5c),  Alt_R (0x6c),  Super_L (0x85),  Mode_switch (0xcb),  Meta_L (0xcd),  Super_L (0xce)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_R (0x86),  Hyper_L (0xcf)
mod5      

But that behaved poorly:

  • left-option-x => Incorrect:
  • left-command-x => Incorrect: M-b
  • right-option-x => Incorrect: M-≈
  • right-command-x => Incorrect: M-b

Note that the 'x' key on Dvorak corresponds to the 'b' key on Qwerty.

Using xev I now get:

left-option:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20512286, (121,123), root:(123,174),
    state 0x0, keycode 203 (keysym 0xff7e, Mode_switch), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

PropertyNotify event, serial 40, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 20512286, state PropertyNewValue

PropertyNotify event, serial 40, synthetic NO, window 0x2000001,
    atom 0x11c (XKLAVIER_STATE), time 20512288, state PropertyNewValue

left-command:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20568312, (140,155), root:(142,206),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

right-option:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20606634, (88,106), root:(90,157),
    state 0x0, keycode 92 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

right-command:

KeyPress event, serial 40, synthetic NO, window 0x2000001,
    root 0x3e, subw 0x0, time 20656211, (126,127), root:(128,178),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

So I'm unclear how to resolve this and get the desired behavior of both option and both command keys being interpreted as meta in Emacs with a Dvorak keyboard.

WilliamKF
  • 183
  • I came across this hoping to find an answer to a similar problem and was disappointed to have such a detailed question but no answer.

    And kudos for Dvorak, which I've used for 20 years or so, and saved my repetitive stress bacon.

    – Fred Douglis Feb 06 '24 at 22:35

0 Answers0