0

I'm trying to run xterm and have it pick up key bindings such as

Ctrl-; 
Ctrl-.
Ctrl-,
etc..

(I like to use these bindings in emacs -nw)

After some reading online I managed to get a working setup on a desktop at the office (which is running fedora 20) using the following line in my ~/.Xresources file:

xterm*formatOtherKeys: 1

But that doesn't seem to work on my home desktop, which is running windows 7 and running Ubuntu 12.04.5 LTS on a VirtualBox. I managed to confirm that the ~/.Xresources file is in fact being loaded (because I can control the font size from within it), but it seems that formatOtherKeys doesn't have the same effect as it has on the desktop at the office.

Does anyone have any idea why it's not picking up those key bindings?

EDIT:

xterm -v returns XTerm(271).

And this is what xdev prints when I press (and release) Ctrl-;

KeyPress event, serial 32, synthetic NO, window 0x3e00001,
    root 0x139, subw 0x0, time 63644841, (806,220), root:(824,274),
    state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x3e00001,
    root 0x139, subw 0x0, time 63645458, (806,220), root:(824,274),
    state 0x14, keycode 47 (keysym 0x3b, semicolon), same_screen YES,
    XLookupString gives 1 bytes: (3b) ";"
    XmbLookupString gives 1 bytes: (3b) ";"
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x3e00001,
    root 0x139, subw 0x0, time 63645579, (806,220), root:(824,274),
    state 0x14, keycode 47 (keysym 0x3b, semicolon), same_screen YES,
    XLookupString gives 1 bytes: (3b) ";"
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x3e00001,
    root 0x139, subw 0x0, time 63645939, (806,220), root:(824,274),
    state 0x14, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
1

Apparently the configuration I should have used is this:

xterm*modifyOtherKeys: 1

Now all the following key bindings are picked up correctly by emacs. You might need to map these in your .emacs in order to use them:

(define-key input-decode-map "\e[46;5u" (kbd "C-."))
(define-key input-decode-map "\e[44;5u" (kbd "C-,"))
(define-key input-decode-map "\e[60;6u" (kbd "C-<"))
(define-key input-decode-map "\e[62;6u" (kbd "C->"))
(define-key input-decode-map "\e[59;5u" (kbd "C-;"))
(define-key input-decode-map "\e[40;6u" (kbd "C-("))
(define-key input-decode-map "\e[41;6u" (kbd "C-)"))
(define-key input-decode-map "\e[49;5u" (kbd "C-1"))
(define-key input-decode-map "\e[39;5u" (kbd "C-'"))
(define-key input-decode-map "\e[45;5u" (kbd "C--"))
(define-key input-decode-map "\e[43;6u" (kbd "C-+"))
(define-key input-decode-map "\e[61;5u" (kbd "C-="))
(define-key input-decode-map "\e[63;6u" (kbd "C-?"))
  • Actually, I do not use emacs (vi like emacs is good enough), but that may help other users of xterm. – Thomas Dickey Mar 30 '15 at 8:15
0

A couple of possibilities to check:

  • formatOtherKeys was added in patch #235 ("xterm -v" should show at least that).
  • the different environment likely has different keycodes underneath. You might see some differences using xev for the combinations you want to use.

Your question did not mention the requisite resource setting for modifyOtherKeys. The formatOtherKeys resource alters the control sequences used by modifyOtherKeys (and you may have overlooked this in reusing the settings on a different system).

For instance, I can use this (on a different system...) to display the modified keys:

xterm -xrm '*modifyOtherKeys:1' -xrm '*formatOtherKeys:1' -e cat -v

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.