From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23572 invoked from network); 28 Mar 2007 14:32:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) 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.8 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 28 Mar 2007 14:32:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 62439 invoked from network); 28 Mar 2007 14:32:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 28 Mar 2007 14:32:36 -0000 Received: (qmail 23702 invoked by alias); 28 Mar 2007 14:32:32 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23245 Received: (qmail 23690 invoked from network); 28 Mar 2007 14:32:30 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 28 Mar 2007 14:32:30 -0000 Received: (qmail 62145 invoked from network); 28 Mar 2007 14:32:30 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 28 Mar 2007 14:32:27 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly42d.srv.mailcontrol.com (MailControl) with ESMTP id l2SEW0Xt003496 for ; Wed, 28 Mar 2007 15:32:25 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 28 Mar 2007 15:29:56 +0100 Date: Wed, 28 Mar 2007 15:29:55 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: completion after < at the start of the line Message-Id: <20070328152955.8a64af07.pws@csr.com> In-Reply-To: <20070327213726.GF4885@sc.homeunix.net> References: <20070327213726.GF4885@sc.homeunix.net> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.10 (GTK+ 2.10.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 28 Mar 2007 14:29:56.0122 (UTC) FILETIME=[8E86A7A0:01C77145] X-Scanned-By: MailControl A-07-06-80 (www.mailcontrol.com) on 10.68.0.152 Stephane Chazelas wrote: > $ mkdir 1 > $ cd 1 > $ touch foo bar > $ zsh -f > sc% < b foo > > (That is type "< b foo" move the cursor back to 4rd character, > then type ) > > Then zsh completes that to: > > sc% < foo foo > > (instead of expected < bar foo). Good news: I know why this happens. Bad news: it's in get_comp_string(), one of the world's most impenetrable functions (but you should see set_comp_sep()). We reset the index into the completion words to zero when the command word arrives. Obviously this is wrong in this case since the argument to the redirection is already there and this overwrites it. However, not setting it to zero at that point is too simple a fix since it messes up handling of multiple commands on a line separated by ";" etc. etc. Unfortunately the handling of the index into the array of words is obscured by one of those typical variables (here called "ins") which gets set to apparently random values in random places in the function, is used in tests all over the place so you're never quite sure what's going on, and is completely undocumented. If we could work out that was doing (and, ideally, document it, although I'm not sure the words don't magically drift off the editor into space if you try) we might be able to work out how to reset the start of line index. An alternative strategy is to record redirections before the command word, but I'd rather understand what's there at present than bolt something new on regardless. -- 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 To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview