[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] READLINE_POINT with multibyte locales
From: |
Koichi Murase |
Subject: |
Re: [PATCH] READLINE_POINT with multibyte locales |
Date: |
Tue, 10 Apr 2018 20:48:19 +0900 |
(I'm sorry. I directly replied to Chet's e-mail address by mistake.
Let me send the reply again to the mailing list.)
Hi Chet,
Thank you for your explanation.
2018-04-10 0:26 GMT+09:00 Chet Ramey <chet.ramey@case.edu>:
> Because the underlying readline variable that it controls, rl_point, is
> kept in bytes -- an index into the line buffer.
Sorry for my poor writing, but my suggenstion is not to change the
meaning of internal variable `rl_point', but to convert the value of
`rl_point' to the number of characters on assigning it to `READLINE_POINT'
and, after the execution of the shell command, to convert
`READLINE_POINT' to the number of bytes on assiging it to `rl_point',
i.e., `READLINE_LINE' is the number of characters while `rl_point' is
kept to be the number of bytes.
Maybe it is easier to see the patch I attached to the first mail which
completely works (at least in my environment).
> If you change this, it
> will set the point to the wrong place in the buffer (exposed to that
> function as READLINE_LINE).
The situation is opposite. Currently, with most of the implementations
of functions to which the `bind -x` binds keys, the point will be set
to wrong places (i.e. in the middle of characters) with the line
containing multibyte characters (see Repeated-By section of my initial
mail). The patch tries to fix it so that it never happens that the
point is set to wrong places.
Thanks,
Koichi
2018-04-10 0:26 GMT+09:00 Chet Ramey <chet.ramey@case.edu>:
> On 4/9/18 10:51 AM, Koichi Murase wrote:
>
>> Bash Version: 4.4
>> Patch Level: 19
>> Release Status: release
>>
>> Description:
>>
>> Currently `READLINE_POINT' counts the number of bytes but not
>> characters. This makes difficult to properly implement shell functions
>> for `bind -x' that uses `READLINE_POINT'. In fact, almost all the
>> implementations of `bind -x' functions which can be found in the
>> internet is broken for this point.
>
> Because the underlying readline variable that it controls, rl_point, is
> kept in bytes -- an index into the line buffer. If you change this, it
> will set the point to the wrong place in the buffer (exposed to that
> function as READLINE_LINE).
>
> --
> ``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/