From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18359 invoked from network); 20 Sep 2006 09:24:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 20 Sep 2006 09:24:08 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 79791 invoked from network); 20 Sep 2006 09:24:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Sep 2006 09:24:02 -0000 Received: (qmail 17704 invoked by alias); 20 Sep 2006 09:23:54 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10745 Received: (qmail 17695 invoked from network); 20 Sep 2006 09:23:53 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 Sep 2006 09:23:53 -0000 Received: (qmail 78635 invoked from network); 20 Sep 2006 09:23:53 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 20 Sep 2006 09:23:51 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly08c.srv.mailcontrol.com (MailControl) with ESMTP id k8K9M48Y024742 for ; Wed, 20 Sep 2006 10:23:13 +0100 Received: from cameurexb01.EUROPE.ROOT.PRI ([10.100.137.61]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 20 Sep 2006 10:06:27 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 20 Sep 2006 10:06:25 +0100 Date: Wed, 20 Sep 2006 10:06:25 +0100 From: Peter Stephenson To: Zsh users list Subject: Fw: Re: _arguments: repeated option with multiple optargs Message-Id: <20060920100625.78614b8e.pws@csr.com> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Sep 2006 09:06:25.0767 (UTC) FILETIME=[0CFAC770:01C6DC94] X-Scanned-By: MailControl A-07-04-02 (www.mailcontrol.com) on 10.67.0.118 I meant to send this to the list, not just to Roman... Roman Neuhauser wrote: > _arguments -s : '*-r=::->file:*:::->test' > > does exactly what the manual say it does, IOW all the remaining words on > the line are to be completed as described by the action. That's not what > I want, though: the whole (-r file 1*test) can be repeated, and I'd like > it to offer also -r. > > Can _arguments do this for me somehow, or is this up to me? I haven't much experience with multiple arguments, but it looks from the manual page like you ought to be able to tell it that it should stop at the next argument that starts with -r; which isn't logically correct, but ought to do the trick: Each optarg following an optspec must take one of the following forms: ... :*pattern:message:action :*pattern::message:action :*pattern:::message:action This describes multiple arguments. Only the last optarg for an option taking multiple arguments may be given in this form. If the pattern is empty (i.e., :*:), all the remaining words on the line are to be completed as described by the action; otherwise, all the words up to a word matching the pattern are to be completed using the action. (Typically, it never actually defines what it means by an "optarg", but it obviously means everything from the first colon onwards.) It's quite possible this isn't well tested. The guy who wrote _arguments (and most of the rest of the completion system) has been in hiding for several years. However, I don't think _arguments is very good at this sort of complexity. Somewhere there's a parser that implements a finite state machine for completion arguments, but currently no one in the entire world understands that. It could do with resurrecting in a more friendly fashion. When things get complicated, I tend to use the *::: form of argument which restricts the command line to the arguments I'm looking at and take it from there. It usually means a call to an additional _arguments (in Unix/Command/_perforce, for example, which isn't a particularly simple example). However, I'm really thinking of the case where you have something like , which is a little different from what you've got. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php