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

Re: Three questions about a completer

On Mon, Sep 12, 2016 at 10:53 PM, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:

> Jesper Nygårds wrote:
> >Again, I want to put a string on the command line, hit
> > alt-e, and only those files having a part matching what i wrote should be
> > offered. If I then reverse the order, I want the same list, i.e. those
> > files matching what I originally wrote.
> Using _menu generally does what I think you're describing. To use that,
> you may want to use _generic instead of _list-result directly. I'd
> recommend using _generic regardless of whether you want _menu, actually.
> Other completers such as _match could also be useful.
>   zle -C list-comp menu-complete _generic
>   zstyle ':completion:*list-comp::::' completer _menu _list-result
Perhaps I am missing something obvious, but I cannot get this to work. I
tried applying your suggestions, and ended up with this:

_list-result() {
    print In _list-result
    local -a hlist=($HOME/*)
    compadd -n -V list_result -M 'l:|=* m:{[:lower:]}={[:upper:]}' -- $hlist

zle -C list-comp menu-complete _generic
zle -C rev-list-comp reverse-menu-complete _generic
zstyle ':completion:*list-comp::::' completer _menu _list-result
bindkey '\ee' list-comp
bindkey '\eE' rev-list-comp

However, something is missing, because completion is not  triggered. In
fact, the debugging line "In _list-result" is not printed, so _list-result
is never called. I assume there is something more that I need to put in
place that I have missed?

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