From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10431 invoked from network); 13 Aug 2006 16:35:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Aug 2006 16:35:22 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 98955 invoked from network); 13 Aug 2006 16:35:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Aug 2006 16:35:13 -0000 Received: (qmail 2989 invoked by alias); 13 Aug 2006 16:35:05 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10597 Received: (qmail 2979 invoked from network); 13 Aug 2006 16:35:05 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Aug 2006 16:35:05 -0000 Received: (qmail 97760 invoked from network); 13 Aug 2006 16:35:05 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 13 Aug 2006 16:35:03 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20060813163502.BXFQ27023.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Sun, 13 Aug 2006 17:35:02 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout02-winn.ispmail.ntl.com with ESMTP id <20060813163502.ILOF23938.aamtaout02-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sun, 13 Aug 2006 17:35:02 +0100 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.7/8.13.7) with ESMTP id k7DGYr8V002934 for ; Sun, 13 Aug 2006 17:34:57 +0100 Message-Id: <200608131634.k7DGYr8V002934@pwslaptop.csr.com> From: Peter Stephenson To: "Zsh Users' List" Subject: Re: Completing a unique prefix of "script" completes "script" In-Reply-To: Message from "Nikolai Weibull" of "Sun, 13 Aug 2006 16:59:54 +0200." Date: Sun, 13 Aug 2006 17:34:53 +0100 "Nikolai Weibull" wrote: > On 8/10/06, Peter Stephenson wrote: > > > zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[.,_-]=**r:|= > **' > > What exactly are the 'r's doing here? That's become a bit garbled: the bit we're referring to should look like 'r:|[.,_-]=** r:|=**' There's a fairly full description of this in MATCHING CONTROL in the zshcompwid manual page---in something of the sense of "I couldn't walk across the English Channel because the sea was fairly full", so I'll summarise here. The general form is r:LPAT|RANCHOR=TPAT where LPAT has to occur on the left of the string already on the command line, RANCHOR indicates something at the right hand end of the string on the line, and TPAT says what sort of pattern to use to try to match the stuff in the middle when looking for possible completions. The LPAT isn't commonly used and if it's empty it has no particularly special meaning. The [.,_-] says look for any part of the code on the command line which has any of the those characters to the right. The ** then says match anything there; a single * wouldn't allow the anchor, i.e. the character out of that set in square brackets, to be matched itself, so you'd have to have typed any anchor characters yourself. The result is that something like u-l-o-h is matched as u*-l*-o*-h. (If we'd used r:|[.,_-]=* those *'s wouldn't have matched further -'s, as we've doubled the * they can.) The r:|=** matches at the end of the string: that's only necessary if you're completing in the middle and want to act as if there was a * there. In other words, without it, u-l-o-h would have been treated as u*-l*-o*-h, with it it's treated as u*-l*-o*-h*. (This supposedly depends on COMPLETE_IN_WORD being set; if it isn't completion always takes place at the end.) Quite why this forces a distinction between script as an executablle and script as a directory is one of the great mysteries of the modern world. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/