zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu
Subject: Re: History !# substitutions
Date: Wed, 29 May 1996 17:20:33 +0200	[thread overview]
Message-ID: <199605291520.RAA18469@hydra.ifh.de> (raw)
In-Reply-To: "pws@ifh.de"'s message of "Wed, 29 May 1996 10:19:06 MET." <199605290819.KAA06804@hydra.ifh.de>

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 <pws@ifh.de>       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.



  reply	other threads:[~1996-05-29 15:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-29  5:33 Bart Schaefer
1996-05-29  8:19 ` Peter Stephenson
1996-05-29 15:20   ` Peter Stephenson [this message]
1996-05-30  4:40     ` Bart Schaefer
1996-05-30  8:33       ` Peter Stephenson
1996-05-30 14:58         ` Bart Schaefer
1996-05-30 15:11         ` Zefram
1996-05-30 16:11           ` Barton E. Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199605291520.RAA18469@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).