From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15202 invoked by alias); 7 Nov 2013 01:11:39 -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: 18111 Received: (qmail 16136 invoked from network); 7 Nov 2013 01:11:33 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=xJPVUTTjAQDtVBMQzgMxGi/u91cq625u38MCmlALj0w=; b=qVMo7UscA9tMaa9BxL33McRKTzdkV0Bq1Veacbx5/iGszO1D7MQJLlXGY4ctI1GYdF 5MHu16mcVbpjZfp5Qn3pAw7tzqhG7DUub02YNmb2GqYyRBwSHhXchao6ntEdrEicfPzf BNriuj5+K/+/Ny4+1jQvJl07OpkPfaA6huGTwls19DxmzIOmeNF/JbiB9YVh0bLA+mdq WwEOq197SU3Q+ksG3QbBoUCxyYhQX0XO12melHAo42sgPQqIPPEQKsuQkgedTrj6AOWy +NeFHq/E4yRU6uRxr/Ykt+wN7uDHZB3i2+m3nFjrCTkx46PFxi4CLkWpGr/wy2PMKNzo ciRw== X-Received: by 10.50.164.165 with SMTP id yr5mr337001igb.38.1383786688049; Wed, 06 Nov 2013 17:11:28 -0800 (PST) Message-ID: <527AE8BF.6090706@gmail.com> Date: Wed, 06 Nov 2013 18:11:27 -0700 From: John User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Re: ordering of file-patterns completions References: <527A5F11.2080701@gmail.com> <131106080319.ZM19160@torch.brasslantern.com> In-Reply-To: <131106080319.ZM19160@torch.brasslantern.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 11/6/13, 9:03 AM, Bart Schaefer wrote: > On Nov 6, 8:24am, John wrote: > } > } I have a tool which needs one file-patterns for the first file matched, > } then the second and the rest should be of a different file-patterns. I > } don't see a way to do this. > > You probably want to write a custom completer with the _arguments utility > function, and to leave file-patterns unspecified. > > > _foo() { > _arguments '1:The first file:_files -g "XXX.*"' \ > '*:All other files:_files -g "*.${words[2]:x}"' > } > > compdef _foo foo > > Here "1:" refers to the first argument (after skipping the command name > and any option flags) whereas "$words[2]" refers to the second word > of the entire command line (first word after the command name), so this > doesn't quite generalize if there may be options (words starting with > a hyphen) between the command name and the first file. If that is the > case, you'll need to do some pre-processing of $words before calling > _arguments to determine which position to reference instead of [2]. Yeah, unfortunately I do. I was using _arguments to process those, and then zstyle to deal with the files. But I'm not quite understanding how to do what you're describing to pre-process them instead of using _arguments. > > (You can skip the "compdef" command if you put the body of _foo in a file > named _foo in a directory referenced in your $fpath, and begin that file > with the line "#compdef foo".) > > } Are there any examples of something similar to this around? > > There are lots of examples of using _arguments in the default set of > completion functions. If there is a standard tool that you know of that > accepts arguments something like your custom one, try looking at the > completion function for that. You can usually find the name of that > function by looking at ${_comps[command-name-here]}. I searched through a number of them, but haven't found anything which has helped yet. John