From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12104 invoked by alias); 15 Dec 2011 22:54:46 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16642 Received: (qmail 18240 invoked from network); 15 Dec 2011 22:54:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=/+8k0xGTWtfK8JRi2zyMmCbrajd4s1EbUWX/DfTFXdI=; b=x9wYlQvVxKqcRtJRA72rECMOu8h32ofDm7JEZkFkbxPG0rjVyW9CJB+23MjP+YpShy zYAsfA1culqIVHtBbh/28oEtMQ0Kma6a8Xkf8+/PsxZH5ZaL94IQ61Ujq5pK39l+89Hp xttNkYsj91siAFkHFEHdLISFRuvitLmeqXIzc= MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 15 Dec 2011 23:54:37 +0100 Message-ID: Subject: Re: Having a tough time setting up completion. From: Mikael Magnusson To: Larry Schrof Cc: "zsh-users@zsh.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 15 December 2011 23:06, Larry Schrof 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 s= yntax to do the following completion. > > I have a command called foo. This command takes exactly one of three form= s: > > foo -x > foo --longword > foo > > -x is a single-letter option, --longword is a double-dashed GNU-style lon= g 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, is a single (non-leading-das= h) word. As soon as this word is entered or completed, no other word from t= he (really large) set should appear on the command line. > > If anyone can offer a general outline as to how I can use _arguments to i= mplement this, that would be great. I need to manually enter in all fifty w= ords at some point, and make them mutually exclusive. Will be interesting t= o 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:... --=20 Mikael Magnusson