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

Re: how to customize _all_matches use?



Vadim Zeitlin wrote:
>  I'd like to have a key binding which would complete all matches which I
> would get by pressing TAB at once. AFAICS from the manual/user guide, this
> is what the all-matches completer is for and so, following the examples
> there, I tried to do the following:
> 
> 	% zle -C all-matches complete-word _generic
> 	% bindkey '^Xa' all-matches
> 	% zstyle ':completion:all-matches:*' completer _all_matches
> 
> However this doesn't seem to work:
> 
> 	% ls
> 	bar  baz  foo
> 	% ls ^Xa # nothing happens
> 
> I do get the behaviour I want if I do
> 
> 	% zstyle ':completion:all-matches:*' completer _all_matches _complete
> 
> but with one extremely annoying side-effect:
> 
> 	% ls ^Xa
> 	% ls bar baz foo # this is the same line completed by the shell
> 	bar baz foo
> 	bar  baz  foo

The following should fix it:

zstyle ':completion:all-matches:*' insert true

This is mentioned in the manual under the style "insert", but you have
to go hunting and have some idea of what you're looking for (I actually
found it by looking at the completer itself.)  The business about the
completer doesn't seemed to be mentioned at all, but I have the same
experience as you.  It looks like the manual needs to be updated.

>  And, of course, I don't really want to have this behaviour so much for ls
> as for other commands where the completion can't be replaced with just '*'.
> For example, it would be very useful to have for "cvs diff" for which I use
> 
> 	zstyle ':completion::complete:cvs-diff:argument-rest:' \
> 		tag-order existing-files removed-files directories
> 
> so that pressing TAB after "cvs di" normally completes only the modified
> files. But pressing ^Xa also completes the sub-directories -- is there any
> way I could avoid this?

I haven't tried this, but you *should* still be able to use the
tag-order style with all-matches.  The context will be different,
though; as in the styles you quoted it should start
':completion:all-matches:'.  If it's not that obvious or nothing works,
let us know.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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