zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
Cc: zsh-users@zsh.org
Subject: Re: _values with controllable duplicates suppression?
Date: Fri, 19 Mar 2021 03:40:46 +0100	[thread overview]
Message-ID: <20158-1616121646.327823@nVvU.T9s4.XE9v> (raw)
In-Reply-To: <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


      reply	other threads:[~2021-03-19  2:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 23:40 Phil Pennock
2021-03-19  2:40 ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20158-1616121646.327823@nVvU.T9s4.XE9v \
    --to=opk@zsh.org \
    --cc=zsh-users@zsh.org \
    --cc=zsh-workers+phil.pennock@spodhuis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).