Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shift arrow selection in emacs

Tags:

emacs

elisp

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])
like image 530
denys Avatar asked Feb 23 '26 12:02

denys


2 Answers

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])
like image 89
jtahlborn Avatar answered Feb 27 '26 04:02

jtahlborn


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

like image 33
Nicolas Dudebout Avatar answered Feb 27 '26 04:02

Nicolas Dudebout



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!