bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should the readline *-meta flags reset when $LANG changes?


From: Koichi Murase
Subject: Re: Should the readline *-meta flags reset when $LANG changes?
Date: Fri, 12 Aug 2022 06:56:21 +0900

2022年8月12日(金) 4:22 Chet Ramey <chet.ramey@case.edu>:
> >> Often enough to make a difference?
> >
> > My `bind -x' functions use `LC_ALL=' and `LC_CTYPE=C' for every
> > keystroke, for example, in combination with `builtin read'.  They also
> > use `LC_ALL=' for other purposes for mostly every keystroke.  Some vi
> > binding also uses `LC_CTYPE=C'.  My completion functions also change
> > `LC_ALL` and `LC_CTYPE`.  For example, `LC_CTYPE=C' is used in
> > calculating a PJW hash code of a given string.  I haven't carefully
> > checked, but there are probably other cases of changing `LC_CTYPE'.
> > Also, `LC_ALL=' is used everywhere.
>
> So you're using `read -e'?

No.

> Otherwise, these suggest that solution 4 is most appropriate.
>
> >> Across multiple calls to readline?
> >
> > I think I am missing the point.  What does ``multiple calls to
> > readline'' mean?  Is the situation different from a single call to
> > readline?
>
> It informs the solution. If I choose option 4, for instance, none of these
> matter.

Ah! Now I understand it. I was misunderstanding option 4. Option 4 works for me.

> Where I think we're converging is to use option 4, and -- as long as
> LC_ALL/LC_CTYPE/LANG don't change -- not modifying these variables when
> readline() is called. I can document that these variables are dependent on
> the current locale, and if the locale changes, those variables will need
> to be adjusted. If the locale doesn't change between calls to readline(),
> you don't need to do anything.

I agree with option 4. Thank you for all your explanations.

--

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:

$ bash-dev --norc
$ echo "$TERM"
screen.xterm-256color
$ bind '"\e[1~": bell'
$ bind -q beginning-of-line
beginning-of-line can be invoked via "\C-a", "\eOH", "\e[H".
$ TERM=dumb infocmp >dumb.ti
$ bind -q beginning-of-line
beginning-of-line can be invoked via "\C-a", "\eOH", "\e[1~", "\e[H".

There are only a few places where TERM can be changed in my
configuration (unlike LANG/LC_* which are changed in many places), so
I can work around them by saving and restoring the keybindings, yet I
think it is more reasonable that automatic rebinding on TERM changes
only happens when the change survives to the next call of readline (as
option 4 for the locale variables).

--
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]