Subject: Re: PATCH: Add SHORT_KEYBIND_DISCARD option
From: Mikael Magnusson <[email-masked]>
To: Oliver Kiddle <[email-masked]>
Cc: zsh workers <[email-masked]>
Date: Thu, 7 Apr 2016 18:07:24 +0200
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Thu, Apr 7, 2016 at 5:25 PM, Oliver Kiddle <[email-masked]> wrote:
> Mikael Magnusson wrote:
>> > Didn't we discuss this issue a few months ago - have you perhaps got a
>> > message reference?
>
> I managed to find this again: users/20358 is a good reference where Bart
> makes the point that this will have unpredictable effects for an unbound
> function key. Some of the thread is in -workers.

I'm not sure what exactly is unpredictable about it. Pressing F1,
you'll see [11~ instead of just the ~. (this is assuming you have some
other F-key bound, if you don't, you'll see 1~ because there's less
common prefix, so you're arguing for something that is already very
inconsistent). I could buy this argument if we ignored the whole key
including the final ~ too, but we don't. In emacs mode it gives you
more hints about what key you actually pressed, and in vi mode, ^[ is
already bound to vi-cmd-mode so the patch doesn't affect this case (it
already caseswaps 11 characters and leaves the user wondering wtf
happened).

> We could make discarding the keys conditional upon whether KEYTIMEOUT
> has elapsed since the prefix was received to account for that, however.
>
>> I think I asked if doing what this patch does was possible, but I want
>> it in general, not only because of bracketed-paste. If it were up to
>> me, this way would be the only way. It doesn't really make any sense
>> to me why we arbitrarily eat input just because it was a potential
>> common prefix that then turned out to not be part of any actual
>> keybinding. But since zsh people tend to like their things not
>> changing, I did the option.
>
> If get a prefixed key combination wrong, a beep seems cleaner than
> getting the latter part inserted.

People do things like bindkey -M viins jj vi-cmd-mode, but i'm sure
they still like to type words beginning with a j. (This works already
because j isn't undefined-key though).

You do have a point for things like ^X^D type stuff though, if I don't
have that bound maybe I don't want to accidentally close the shell.
(For weird people that don't use ignoreeof). :)

In my favor though, consider pressing alt-up from zsh -f in emacs
mode. Without the change, it will beep and insert [A, and with the
change it will beep (from the single escape), and then invoke the
up-line-or-history binding of the up key. That's better, arguably.

>> It just seems like a much more correct way of doing it to me.
>
> But is it also proving an irritation in actual practice? Are you often
> typing part of a long emacs-style binding and then being distracted by
> something in another window, perhaps?

I suppose it isn't.

> Would a separate timeout after which a prefix is discarded perhaps make sense?

I've sometimes harbored thoughts about allowing per-prefix timeouts even :).

Overall, I guess I'm a little bit less decided now than when I started
the thread.

-- 
Mikael Magnusson