Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Limitations of menuselect
- X-seq: zsh-workers 31073
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Olivier Teuliere <ipkiss@xxxxxxxxx>
- Subject: Re: Limitations of menuselect
- Date: Wed, 27 Feb 2013 18:27:31 +0100
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1361986052; bh=f8WoEil8CflvXKqABPqI2AE2oe8Nmt2H6LloQu4T638=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:cc:In-reply-to:From:References:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=XgkbKQLWjwd41n1B5tkEAEHsfhdIF5/lCE7NAcfckzaMZtE3Rl8zJ9YBlf9PsdEXT0usSnVWGyD3Tlv7ArzuO56CyZTooFLZgot17eTEDaDYYzDgAwOF2o6X9uMnwWt9RFuZwf5DhB+hIGb+5jGNTddkOKvlST4yrSX9lJeFVQU=
- In-reply-to: <CAKuJizHT3YX_xB-t7pxoKHs_q3z-KbJCrdwfHjBNTPL-znqbvQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKuJizHT3YX_xB-t7pxoKHs_q3z-KbJCrdwfHjBNTPL-znqbvQ@mail.gmail.com>
Olivier Teuliere wrote:
> 1) Custom bindings don't work. You can try it with the following:
> my-widget() { zle down-line-or-history }; zle -N my-widget;
> bindkey -M menuselect k my-widget
> (replacing "my-widget" with "down-line-or-history" in the bindkey
> command works as expected).
Yes, unfortunately it isn't possible.
> Someone told me on IRC that in menuselect a hard-coded table is used
> to lookup the widget names.
More or less. It seems any keybinding picked up from the main keymap
will work though menu selection is exited first. For anything from the
menuselect keymap, it hard codes the actions with various widgets being
overloaded from their original meanings. I'm not sure that I get the
point of this. If it meant that your existing key-bindings would do
something appropriate it might make sense but you do have to duplicate
them in the menuselect keymap. Was this perhaps a bug introduced later
such as when local keymaps were added? In any case, I'd have thought it
was simpler if there were separate widgets - e.g. menu-up-entry instead
of up-line-or-history being overloaded.
> 2) Moving the selected menu item line by line is nice, but scrolling
> several lines at a time would be nicer (that's what I would expect
> PageUp and PageDown to do by default in menuselect, for example). I
> couldn't find an existing widget for that.
You can do some hacks with bindkey -s. For example:
bindkey -M menuselect j down-line-or-history
bindkey -M menuselect -s n 'jj'
What you can do with that is limited. Also, it doesn't cope well with putting
escapes in the latter string.
> 3) When using the reverse-menu-complete widget to open menuselect, I
> would like to select the last result, not the first one (otherwise I
> can use menu-complete directly...). It doesn't sem to be possible at
> the moment.
That seems like a bug to me.
> 4) When moving the selection in the menu, the inserted text changes.
> But for some reason, the accept-line widget only closes the menu,
> without accepting the line. So to really accept the line I have to
> call accept-line again (basically, I have to hit Enter twice). This
> behavior seems a bit backwards: if I wanted to accept the current
> selection, which is already inserted, I could simply go on typing, I
> don't need an extra validation step. So, would it be possible to have
> accept-line really accept the line? :) If the current behavior is
> still wanted, it could maybe be called "accept-selection", because the
> current name is misleading...
This probably wouldn't be hard to implement if we keep to the scheme of
overloading existing widgets.
You can abuse the behaviour I described earlier to make Enter really
accept the line:
bindkey -M menuselect -r '^M'
zle -N new-accept-line
new-accept-line() {
zle .accept-line
}
bindkey '^M' new-accept-line
But don't do this because it'll break the enter key in other contexts
(reading from the mini-buffer). To replace accept-line without breaking
things you need to use zle -A but that won't work here.
> 5) Apparently, menuselect always inserts the selected text. But if
> there was a way (maybe using a style) to select a menu entry without
> inserting the corresponding text, it could allow a killer feature:
> typing characters could shrink the list of results (for example, by
> binding individual letter keys to an appropriate widget...
Actually, this is possible. Bind a key to vi-insert in menuselect and
you get "interactive" mode which does this. Still, there is a lot of
ways this could be better. Unfortunately, you stay in the menuselect
keymap at this point which is irritating if you've, for example, bound /
to history-incremental-search-forward.
I can't think of a way to go straight into this mode. The bindkey -s
trick stuck it in an infinite loop.
> accept-line-and-infer-history maybe?), while still allowing to select
That also does something similar already:
bindkey -M menuselect '^M' accept-and-infer-next-history
then enter will keep in menu selection.
> I hope that these remarks make sense and that I haven't overlooked
> some existing features...
It certainly makes sense and is quite thought provoking. I'm only sorry
that my answers aren't especially helpful.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author