[Top][All Lists]

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

Re: yank-last-arg with numeric argument doesn't work as intended in vi m

From: Chet Ramey
Subject: Re: yank-last-arg with numeric argument doesn't work as intended in vi mode
Date: Tue, 9 Jun 2020 10:00:04 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 6/8/20 9:33 PM, Leo Alekseyev wrote:
> On Mon, Jun 8, 2020 at 3:30 PM Chet Ramey <chet.ramey@case.edu> wrote:
>> ................
>> On 6/8/20 12:46 AM, Leo Alekseyev wrote:
>>> set keymap vi-insert
>>> "\e.":yank-last-arg
>> Even with those first two changes, which will be in the next bash devel
>> branch push, you'll have to be very careful with this. This key binding
>> introduces ambiguity: either you want to run the function bound to ESC,
>> which puts you into vi command mode, or you want to run yank-last-arg or
>> any other function with an ESC meta prefix. Readline has to read an
>> additional character to disambiguate, and it needs to read it with a half
>> second or so to be part of the key sequence (this is the standard readline
>> way to tell the difference between ambiguous prefixes). If you take longer
>> than a half second, you might find yourself running the `.' (redo) command.
> Thank you for fixing this bug. Regarding the ambiguity, it is my
> assumption that the intended use of bindings like "\e." in vi mode is
> to enable alt/meta chords, i.e. the user would never actually want to
> press "ESC ." to invoke the yank-last-arg or whatever else function.

You might be surprised.

> With this in mind, as it stands, "M-." would invoke yank-last-arg
> immediately (with the above binding), while "ESC ." would invoke the
> redo command (with the 500 ms timeout after ESC). Empirically, the 500
> ms ESC timeout does not result in usability issues. So it seems that
> such bindings while technically ambiguous are not problematic given
> the intended use case; correct me if I'm wrong on this.

I think you're right on the behavior of the meta-prefixed sequences -- I
originally put the timeout in to handle the arrow keys -- but it depends on
what your terminal does. If you have it set up to use ESC as the meta
prefix, it will all work with escape-prefixed key sequences as you intend.
If you have it set up some other way, say to enable non-ASCII character
entry, you'll find yourself having to hit ESC and the timeout will kick in.

``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/

reply via email to

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