Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: History !# substitutions
- X-seq: zsh-workers 1219
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: History !# substitutions
- Date: Wed, 29 May 1996 17:20:33 +0200
- In-reply-to: "pws@xxxxxx"'s message of "Wed, 29 May 1996 10:19:06 MET." <199605290819.KAA06804@xxxxxxxxxxxx>
pws@xxxxxx 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 <pws@xxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author