From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18699 invoked from network); 27 Nov 2007 21:59:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 Nov 2007 21:59:50 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 63716 invoked from network); 27 Nov 2007 21:59:43 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Nov 2007 21:59:43 -0000 Received: (qmail 28177 invoked by alias); 27 Nov 2007 21:59:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24125 Received: (qmail 28162 invoked from network); 27 Nov 2007 21:59:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Nov 2007 21:59:39 -0000 Received: (qmail 63390 invoked from network); 27 Nov 2007 21:59:39 -0000 Received: from mtaout03-winn.ispmail.ntl.com (81.103.221.49) by a.mx.sunsite.dk with SMTP; 27 Nov 2007 21:59:32 -0000 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20071127215936.IMCA26125.mtaout03-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Tue, 27 Nov 2007 21:59:36 +0000 Received: from pws-pc.ntlworld.com ([82.6.96.116]) by aamtaout04-winn.ispmail.ntl.com with SMTP id <20071127215920.MWEE29112.aamtaout04-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Tue, 27 Nov 2007 21:59:20 +0000 Date: Tue, 27 Nov 2007 21:58:45 +0000 From: Peter Stephenson To: Zsh Hackers List Subject: Re: matcher-list question Message-Id: <20071127215845.bda5b747.p.w.stephenson@ntlworld.com> In-Reply-To: <200711270956.lAR9ur36020646@news01.csr.com> References: <20071119160702.GB29766@spiegl.de> <20071127084203.GA4034@spiegl.de> <200711270956.lAR9ur36020646@news01.csr.com> X-Mailer: Sylpheed 2.3.1 (GTK+ 2.10.14; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 27 Nov 2007 09:56:53 +0000 Peter Stephenson wrote: > Andy Spiegl wrote: > lama:~>zsh -f > lama% autoload -U compinit; compinit -C > lama% zstyle ":completion:*" matcher-list 'r:|[-./_]=* r:|=*' '+l:|=*' Note that zstyle ":completion:*" matcher-list 'r:|[-./_]=* r:|=* l:|=*' shows the same problem slightly more simply. > lama% ls > foo-bar-abc foo-bar-def foo-bar-geh > lama% ls bar > lama% ls -foobar- > > There's a bug somewhere in the code that assembles partial lines using > matching in this fashion (the code that generates the lists seems to be > OK, or at least the list of matches is correct). I've got at least somewhere... This is mostly for my benefit, in case I forget. I can't imagine anyone else taking the slightest bit of interest. add_match_part() in compatch.c is responsible for assembling the bits of the match ("cline" structures), including prefixes, anchors, and suffixes. In the case in question, "-" is the anchor with "foo" as a prefix. However, the code at line 352, if (m && (m->flags & CMF_LEFT)) { lp->flags |= CLF_SUF; lp->suffix = lp->prefix; lp->prefix = NULL; } kicks in because this is a left anchor, which swaps the suffix and the prefix. I confirmed that commenting out this code gets the completion right in this particular case (with no obvious side effectis, though it presumably screws up in other completions or with other matchers). Still to understand: where left anchoring is actually coming in seeing as the "-" in the matcher in use is in an expression which is marked as a right anchor (yes, I checked that even in Svenland an 'l' in the matcher is associated with CMF_LEFT). The only left anchor is the 'l:|=*', which anchors to the start of the command line; it should be this that's matching the "foo" because it's only matched by virtue of the wildcard at the start of the line, but I don't see why it's handling the first "-". If I could understand why the "-" appeared here instead of associated with a matcher with CMF_RIGHT, I might get further. However, that's quite enough for one night. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/