From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id BAA25676 for ; Thu, 30 May 1996 01:38:47 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id LAA04772; Wed, 29 May 1996 11:21:01 -0400 (EDT) Resent-Date: Wed, 29 May 1996 11:21:01 -0400 (EDT) Message-Id: <199605291520.RAA18469@hydra.ifh.de> To: zsh-workers@math.gatech.edu Subject: Re: History !# substitutions In-reply-to: "pws@ifh.de"'s message of "Wed, 29 May 1996 10:19:06 MET." <199605290819.KAA06804@hydra.ifh.de> Date: Wed, 29 May 1996 17:20:33 +0200 From: Peter Stephenson Resent-Message-ID: <"gRNT01.0.UA1.Tj6hn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1219 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu pws@ifh.de wrote: > I hope flakiness can now be avoided entirely. Did I really say that? This additional patch fixes up things like % print !#:$:s/i/o/o pronto which even after the last patch was choking because the number of words available was not being counted properly, so it couldn't count back from the end of the line. At this point, the end of the line is the last word to be slurped, which may or may not be obvious. I think this is useful, since you quite often need to do things to the previous word on the line. It's not consistent with lines other than the current one, but if it does anything, it has to be this. I added to the manual entry in case it's not clear. (If the manual entry is wrong it's a bug.) *** Src/hist.c.nwords Wed May 29 10:12:15 1996 --- Src/hist.c Wed May 29 16:58:24 1996 *************** *** 181,186 **** --- 181,198 ---- return 0; } + /* Get the maximum no. of words for a history entry. */ + + /**/ + int + getargc(Histent ehist) + { + if (ehist == curhistent) + return chwordpos ? chwordpos/2-1 : 0; + else + return ehist->nwords-1; + } + /* Perform history substitution, returning the next character afterwards. */ /**/ *************** *** 199,205 **** isfirstch = 0; inungetc(hatchar); if (!(ehist = gethist(defev)) ! || !(sline = getargs(ehist, 0, ehist->nwords-1)) || getsubsargs(sline) || !hsubl) return -1; subst(&sline, hsubl, hsubr, 0); --- 211,217 ---- isfirstch = 0; inungetc(hatchar); if (!(ehist = gethist(defev)) ! || !(sline = getargs(ehist, 0, getargc(ehist))) || getsubsargs(sline) || !hsubl) return -1; subst(&sline, hsubl, hsubr, 0); *************** *** 318,331 **** /* extract the relevant arguments */ ! argc = ehist->nwords - 1; if (c == ':') { cflag = 1; c = ingetc(); if (c == '%' && marg != -1) { if (!evset) { ehist = gethist(defev = mev); ! argc = ehist->nwords-1; } else { zerr("Ambiguous history reference", NULL, 0); while (c != '\n' && !lexstop) --- 330,343 ---- /* extract the relevant arguments */ ! argc = getargc(ehist); if (c == ':') { cflag = 1; c = ingetc(); if (c == '%' && marg != -1) { if (!evset) { ehist = gethist(defev = mev); ! argc = getargc(ehist); } else { zerr("Ambiguous history reference", NULL, 0); while (c != '\n' && !lexstop) *** Doc/zshexpn.man.nwords Wed May 29 17:14:23 1996 --- Doc/zshexpn.man Wed May 29 17:16:09 1996 *************** *** 804,810 **** .IR str . .TP .B !# ! Refer to the current command line typed in so far. .TP .BR !{ .\|.\|. } Insulate a history reference from adjacent characters (if necessary). --- 804,812 ---- .IR str . .TP .B !# ! Refer to the current command line typed in so far. The line is ! treated as if it were complete up to and including the word before the ! one with the !# reference. .TP .BR !{ .\|.\|. } Insulate a history reference from adjacent characters (if necessary). -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.