Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _values with controllable duplicates suppression?
- X-seq: zsh-users 26581
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: _values with controllable duplicates suppression?
- Date: Fri, 19 Mar 2021 03:40:46 +0100
- Archived-at: <https://zsh.org/users/26581>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-03/20158-1616121646.327823%40nVvU.T9s4.XE9v>
- In-reply-to: <YFPk6CEytUy/3FXI@fullerene.field.pennock-tech.net>
- List-id: <zsh-users.zsh.org>
- References: <YFPk6CEytUy/3FXI@fullerene.field.pennock-tech.net>
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