Shift up-arrow does not select emacs iterm2 text

I recently helped fix M-left , etc. here: emacs in the terminal meta arrow keybindings , but I cannot fix Shift-up with a similar solution. When I try Shift-up , I get the error <select> is undefined . I tried reassigning it using:

 (add-hook 'term-setup-hook '(lambda () (define-key function-key-map "\e[1;9A" [M-up]) (define-key function-key-map "\e[1;9B" [M-down]) (define-key function-key-map "\e[1;9C" [M-right]) (define-key function-key-map "\e[1;2A" [S-up]) (define-key function-key-map "\e[1;9D" [M-left]))) 

But the shift remains undefined. I also tried to restore the key by setting it using the escape sequence returned from cat , which is ^[[1;2A . Oddly enough, the shift works. shift-select-mode also marked as t .

+6
source share
2 answers

This sounds like a problem accessing an Ubuntu 12.04 machine through Putty when END forced Emacs 23.3.1 to say <select> is undefined . This turned out to be a problem with terminfo , which allows programs to use terminals in a device-independent way.

Based on this discussion of the 2008 bug report, I solved my problem by adding the following to the beginning of my ~ / .bashrc:

 #so the END key will work correctly in Emacs over PuTTY TERM=xterm-vt220 

NB, either with xterm-vt220 or default xterm, emacs -Q -nw gets ESC [ 4 ~ when I press END, ESC OA for Up and ESC [ A for Shift-Up. (To find out which Emacs code codes are received, press a few buttons and then Ch,l .) For the same keys, in the same order, cat says [4~ , [A and [OA ... so Up and Shift-Up are weird upside down.


If you don't want to change your terminfo, see this discussion for a workaround http://lists.gnu.org/archive/html/help-gnu-emacs/2011-05/msg00211.html

You should be able to get around the problem with something like:

(define-key input-decode-map "\e[1;2A" [S-up])

And in order for this to take effect at the right time, you will need to use something like in your .emacs:

(if (equal "xterm" (tty-type)) (define-key input-decode-map "\e[1;2A" [S-up]))

+9
source

Just add more solution information: https://github.com/arthurnn/dotfiles/blob/8d56f2419da9a4cb654d8941f379d6d5783bdb90/.emacs.d/init.d/setup-bindings.el#L3-L10 , this should fix all cases, including emacsclient . The last line is responsible for committing Shift-up when using emacsclient.

+2
source

Source: https://habr.com/ru/post/917303/


All Articles