denys
denys

Reputation: 2519

Shift arrow selection in emacs

I'm using GNU Emacs 23.2.1
my init.el

(cua-mode 1)               
(transient-mark-mode 1)    
(setq shift-select-mode t) 
(global-linum-mode 1)      
(show-paren-mode 1)        
(desktop-save-mode 1)      

So, instead of selection I get 2C on Shift =>, 2D on Shift <=, etc. How to solve this?

P.S.
cat -v for Shift <=
^[[1;2D
cat -v for Shift =>
^[[1;2C

How I can map properly those keys to shift-left, shift-right corresponding?

P.P.S.
Sorry. I've forgot. I'm also using screen.

den@playground:~/.emacs.den$ echo $TERM  
screen  

Solution:

(define-key input-decode-map "\e[1;2D" [S-left])  
(define-key input-decode-map "\e[1;2C" [S-right])  
(define-key input-decode-map "\e[1;2B" [S-down])  
(define-key input-decode-map "\e[1;2A" [S-up])  
(define-key input-decode-map "\e[1;2F" [S-end])  
(define-key input-decode-map "\e[1;2H" [S-home])

Upvotes: 3

Views: 2732

Answers (2)

jtahlborn
jtahlborn

Reputation: 53694

This means emacs and your terminal do not agree on what the various key codes mean. there are more advanced ways to configure terminals (terminal specific files), but to get you started, try adding something like this to your emacs init file:

(define-key input-decode-map "\e[1;2D" [S-left])
(define-key input-decode-map "\e[1;2C" [S-right])

Upvotes: 6

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

This usually happens when you run emacs in a console. Try running emacs as a graphical program and this should not be an issue.

Upvotes: 2

Related Questions