Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: menuselect and history



On Apr 19,  7:20pm, Oliver Kiddle wrote:
> 
> Bart wrote:
> > emulate -L zsh
> > zmodload -i zsh/parameter || return 1
> 
> I would tend to be inclined to use _generic to avoid needing such setup
> code.

Does that succeed in forcing menu-selection to always be used?  Normal
menu completion can't work here because you're completing multiple words
simultaneously -- one word (the command) is being replaced by many (the
whole command line, possibly many lines), and that confuses the heck out
of the completion system because the semantic context isn't the same in
all the "matches."  Hence this ...
> effectively operating outside of compsys, using raw compwid.
... is, in this case, partly intentional.

> I wonder if we should make #compdef -k, make widgets go through
> _generic somehow.

That can be solved by having the function redefine itself like so:

--- 8< --- snip --- 8< ---
#compdef -k menu-select ^X:
zle -C history-select menu-select _generic
zstyle ':completion:history-select::::' completer _history_select
bindkey '^X:' history-select

_history_select() {
  # ... my original function body here ...
}

_generic "$@"
--- 8< --- snip --- 8< ---

Presumably `compdef' could be fixed up to do the equivalent when passed
the correct options.  I'd recommend leaving -k as it is and adding a new
option to automatically apply the _generic wrapper.



Messages sorted by: Reverse Date, Date, Thread, Author