From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3223 invoked by alias); 2 Dec 2011 16:15:33 -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: 16596 Received: (qmail 9122 invoked from network); 2 Dec 2011 16:15:31 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Fri, 2 Dec 2011 16:15:19 +0000 From: Peter Stephenson To: Subject: Re: Q: _regex_arguments problem Message-ID: <20111202161519.3adb17bf@pwslap01u.europe.root.pri> In-Reply-To: <20111202131418.GA18623@altlinux.org> References: <20111202131418.GA18623@altlinux.org> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.11.233] X-Scanned-By: MailControl 7.6.4 (www.mailcontrol.com) on 10.68.0.118 On Fri, 2 Dec 2011 17:14:18 +0400 "Alexey I. Froloff" wrote: > I want to complete --variants option argument as a > comma-separated list of variants, like > > fubar --variants one,two,four > > The only example of _regex_words/_regex_arguments usage is ip(8) > completion, but it doesn't use such syntax. Even though I didn't use this in _ip I don't think it's too hard if you approach it the right way... The key point is that in this case you are given the whole command line at once, joined with NULLs --- you are not matching against individual words, you are partially matching bits of the command line until you get to the command position, at which point it tries to complete whatever the possible matches are at that point. (That's why you tend to get all those $'\0' strings around --- they're specifying the end of a word.) So the idea is that when you have matched up to "fubar --variants one", you need to tell it that at this point either you get end of word and a new argument, or you get a "," and another variant. If I'm right, that ought to be fairly straightforward (but I've completely forgotten about the details). If I'm wrong, the may be some special fact about matching the end of a word that I haven't twigged. But I *think* it's general enough to cope. -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog