2

I changed the value of TERM to screen-256color from xterm and it effects the key-bindings in Emacs. Mainly the bindings that use the arrow keys now inserts A,B,C,D instead of running backward-word and forward-word ect. How should I set up 256 colors without affecting the key-bindings.

  • Have you tried xterm-color for your TERM? most modern termcap/curses have the 256-color variant – Drav Sloan Aug 21 '13 at 19:14
  • xterm-color doesn't seem to do the trick. Seems screen-256color is needed for powerline – iiSeymour Aug 21 '13 at 19:21
  • Sorry, that should of been TERM=xterm-256color :) – Drav Sloan Aug 21 '13 at 19:29
  • xterm-256color does the trick although the choice of colors emacs uses for syntax highlighting isn't as appealing. – iiSeymour Aug 21 '13 at 19:36
2

Terminals only understand characters, not keys, so keys that are not printable characters are encoded as control characters or escape sequences.

Different terminals send different escape sequences for some keys. Fortunately, there's no conflict on common terminals: you can declare the escape sequences without worrying about which terminal you're on.

Use C-c h or C-q followed by the function key to see what escape sequence it sends.

(define-key input-decode-map "\eOA" [up])
(define-key input-decode-map "\eOB" [down])
(define-key input-decode-map "\eOC" [left])
(define-key input-decode-map "\eOD" [right])
(define-key input-decode-map "\e[A" [up])
(define-key input-decode-map "\e[B" [down])
(define-key input-decode-map "\e[C" [left])
(define-key input-decode-map "\e[D" [right])

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.