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

Re: _values with controllable duplicates suppression?



Phil Pennock wrote:
> I really like the way that `_values -w` means that if I have already put
> a given repo onto the command-line, it's not offered again.

I wouldn't use _values just for that feature. Try passing -F words (or
-F line if using _arguments) to compadd.

> My problem is that sometimes there's an organization with the same name
> as one of the repos inside that organization.  Eg, "foo/foo" as well as
> "foo/bar", "foo/baz", so if I do:
>
>   git grab -o foo <TAB>
>
> then the "foo" result is suppressed because `_values -w` sees that `foo`
> is already on the command-line, and I'm only offered `bar` and `baz`.

It is ignoring the contents of the $words array so you can manipulate
that (plus $CURRENT) to only cover the final arguments. Actually,
it is probably using $words[2,-1]. You can use two colons after the
asterisk in the _arguments spec to strip down the words array:

   '*::repo:_github_repos_for'

You may be better off with '*:::repo:= _github_repos_for' actually.
Depends how many normal arguments there are. That sets $words to
only those covered by this spec and then the = makes it add a fake
one for the command-position.

Oliver




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