From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26648 invoked from network); 28 Aug 2001 06:19:34 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Aug 2001 06:19:34 -0000 Received: (qmail 25968 invoked by alias); 28 Aug 2001 06:19:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15715 Received: (qmail 25955 invoked from network); 28 Aug 2001 06:19:22 -0000 Message-ID: <20010828061920.57606.qmail@web10406.mail.yahoo.com> Date: Mon, 27 Aug 2001 23:19:20 -0700 (PDT) From: Felix Rosencrantz Subject: Re: Working with the historywords special parameter To: zsh-workers@sunsite.dk In-Reply-To: <1010824170526.ZM28196@candle.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii --- Bart Schaefer wrote: >Have you tried using $history instead of $historywords? You want the >word that comes immediately after $words[CURRENT-1] in every history >line that contains $word[CURRENT-1], right? > > local w p h r > w=${(q)words[CURRENT-1]} > p=$'\0'$w$'\0' > h=$'\0'${(pj:\0:)${(z)history[(R)*$w*]}} > r=( ${${(ps:\1:)h//$~p/$'\1'}%%$'\0'*} ) > compadd -a r > >This assumes there are no literal NUL or ctrl-A characters in the >history, but that seems a pretty safe assumption. I tried Sven's suggestion and that worked fine. I then tried Bart's suggestion, and that worked really fast. However, there were two problems. One a seg fault in the shell when completing for a word that had either one or no matches (stack in a separate post). The other problem is that it didn't know about line boundaries. So if the searched for word was at the end of the line, then it would return a match for the previous command, which is wrong. I didn't try Bart's other suggestion for getting indexes. So don't have anything to say about that versus a new "M" modifier. Also, I was wondering if the (z) modifier applied to the elements of history would always return the same results as found by historywords? -FR __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/