From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: zsh-users@zsh.org
Subject: Setting state in _arguments
Date: Wed, 16 Jan 2013 10:47:09 +0100 [thread overview]
Message-ID: <CABZhJg-ph80A7ZWAGH+ss4eoBoZz_f3OaGkxkEyf7-znNi=4Dw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]
I am trying to improve the completion for the gradle command, and have run
into something I cannot explain. To simplify things as much as possible, I
have constructed this example file, calling it _myfoo:
#compdef myfoo
local curcontext="$curcontext" ret=1 state
_arguments -C \
'--option1' \
'--option2' \
'*:a subcommand:->subcommand' \
&& ret=0
if [[ -n $state ]]; then
print state: $state > /dev/pty2
fi
return ret
On the command line, I write: "myfoo --<tab>", and the completion kicks in
and gives me the options "--option1" and "--option2", which is what I
expected. However, on /dev/pty2 I see "state: subcommand", which I did NOT
expect. I would have thought that since only "--option1" or "--option2"
could possibly match after "--", state would not have been set*, *but it is.
The trouble with this is that in the gradle completion, the possible
subcommands are generated inside the if statement in this case, and thatis
time consuming. I would thus like to avoid going into it when the "--" on
the command line indicates that an option should be completed.
I would have thought that the call to _arguments did not set state since
found some matching options, but obviously I am using it incorrectly. What
should I do instead?
next reply other threads:[~2013-01-16 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 9:47 Jesper Nygårds [this message]
2013-01-16 13:43 ` Oliver Kiddle
2013-01-17 6:39 ` Jesper Nygårds
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='CABZhJg-ph80A7ZWAGH+ss4eoBoZz_f3OaGkxkEyf7-znNi=4Dw@mail.gmail.com' \
--to=jesper.nygards@gmail.com \
--cc=zsh-users@zsh.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).