Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Having a tough time setting up completion.
- X-seq: zsh-users 16643
- From: Larry Schrof <larrys@xxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: Having a tough time setting up completion.
- Date: Fri, 16 Dec 2011 00:17:52 +0000
- Accept-language: en-US
- Cc: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=CGY2LZvwAUqc41QxNk6MPKvtXef3Z/BdC0os1cFF/eU=; b=QH7RIl5CoKe7F9wpZOpkok1JokA5ky3opWX69s569C09ieqBVxpHk65qVZRrfNz7uE1l eOeOsLNeaz/mHyuLURGyLe0rB/LlMovu0LxrXeiZ38RmiivJTtr8Ow1rMTxiUh7A7ABt koolG8vjgh6bi38k8dWsZl43XvH8SFJEN4o=
- In-reply-to: <CAHYJk3QdEp3pp2FLG6ZvmHHFcwK3sjS8VY-dQzqkv8cZOxyXQg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Thread-index: AQHMu3XdAqNB7xXbw0yZ5vB/QP2nIZXeCDqA//+RJgA=
- Thread-topic: Having a tough time setting up completion.
Thanks - this is definitely getting there.
However, I have a problem. Many, but not all, of the strings in this set
contain internal hyphens. For example, we have 'create', 'delete', and
'add-property'.
Adding create and delete to the list of strings works great.
$ foo --<TAB> # yields...
$ foo --longword # Awesome!
$ foo --longword <TAB> # Offers up 'create' and 'delete' - fantastic
When we try adding a hyphenated string into the mix, things break:
$ foo -<TAB> # completes incorrectly to
$ foo add-property # This should have offered -x and --longword as
completions
Any suggestions?
On 12/15/11 2:54 PM, "Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
>On 15 December 2011 23:06, Larry Schrof <larrys@xxxxxx> wrote:
>> I've spent a lot to time studying the zshcompsys man page (the docs for
>>_arguments specifically), but I"m still having a tough time specifying
>>the syntax to do the following completion.
>>
>> I have a command called foo. This command takes exactly one of three
>>forms:
>>
>> foo -x <exactly-one-of-fifty-strings>
>> foo --longword <exactly-one-of-fifty-strings>
>> foo <exactly-one-of-fifty-strings>
>>
>> -x is a single-letter option, --longword is a double-dashed GNU-style
>>long option. (These two options are synonymous.) Of these two options,
>>either zero or exactly one of them should appear. IF one of them
>>appears, it must appear immediately after foo (separated from foo, of
>>course, by whitespace).
>>
>> In all cases, <exactly-one-of-fifty-strings> is a single
>>(non-leading-dash) word. As soon as this word is entered or completed,
>>no other word from the (really large) set should appear on the command
>>line.
>>
>> If anyone can offer a general outline as to how I can use _arguments to
>>implement this, that would be great. I need to manually enter in all
>>fifty words at some point, and make them mutually exclusive. Will be
>>interesting to see how to do that. Thanks!
>
>I'm not sure if I should be happy or sad I got this on the first try
>without even using backspace, without looking anything up, and it
>worked (all on one line if gmail breaks it):
>
>compdef '_arguments ''(-x --longword)''{-x,--longword}''[something]''
>''1:fiftystrings:(one two three and so forth fifty)''' foo
>
>(i use rcquotes so you want '\'' instead of '', or more likely,
>putting the whole quoted string in a regular completer.)
>If you want to give a description for each words, use double parens
>instead and separate desc with :, as
>...:fiftystrings:((one:a\ description\ of\ one two:...
>
>--
>Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author