[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should the readline *-meta flags reset when $LANG changes?
From: |
Chet Ramey |
Subject: |
Re: Should the readline *-meta flags reset when $LANG changes? |
Date: |
Mon, 14 Nov 2022 10:22:04 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 8/11/22 5:56 PM, Koichi Murase wrote:
Can we also change the behavior of TERM in a similar way with option
4? Currently, a temporal change of TERM clears keybindings of some
keys (home, end, right, left, etc.) even when the temporal change does
not survive across multiple calls of readline:
I finally got back to look at this, and I couldn't reproduce it. That was
expected, since the arrow key binding functions are pretty careful not to
overwrite an existing binding. Then I figured out what was going on.
$ bash-dev --norc
$ echo "$TERM"
screen.xterm-256color
$ bind '"\e[1~": bell'
This unbinds the key sequence, since `bell' is not a valid bindable command
name. I happened to be using `previous-history' and testing with "\eOH",
which rebinds it instead.
$ bind -q beginning-of-line
beginning-of-line can be invoked via "\C-a", "\eOH", "\e[H".
$ TERM=dumb infocmp >dumb.ti
Bash does call rl_reset_terminal here when restoring the original value of
TERM, and it attempts to bind the arrow keys and the other specials (Home,
etc.). It finds that "\e[1~" is not bound, and binds it.
$ bind -q beginning-of-line
beginning-of-line can be invoked via "\C-a", "\eOH", "\e[1~", "\e[H".
I think the "TERM=$TERM" idiom to reset the readline terminal settings
without overwriting existing key bindings is useful enough to retain the
current behavior.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Re: Should the readline *-meta flags reset when $LANG changes?,
Chet Ramey <=