zsh-workers
 help / color / mirror / code / Atom feed
From: hzoli@cs.elte.hu (Zoltan Hidvegi)
To: zsh-workers@math.gatech.edu (zsh-workers)
Subject: Further completion fixes
Date: Mon, 24 Jul 1995 12:21:11 +0100 (MET DST)	[thread overview]
Message-ID: <9507241021.AA05677@turan.elte.hu> (raw)

The patch velow fixes several bugs:

1. Parameter completion did not work after an equals:

% echo =$V_<TAB>
% echo \= _

2. Expansion did not work in some cases. E.g.

% foo=
% echo ~/$foo+<TAB>   BEEEP

It should give

% echo ~/_

3. \~ and \= was treated as they were unquoted. Zefram tried to fix it in
article 241. He tested if the ~ or = was a token or a normal character.  I
wrote then that there is something wrong with this approach.  Now I remeber
the problem (I had a correspondence about that with Sven sometime in March and
it took me some time to recall the details).  So if the a line contains some
wildcards and expand-or-complete was requested, first an expansion is tried.
If it doesn't change the line (no match) then completion is tried but now the
wildcard are treated as normal characters.  For that the parsed word is
untokenized before calling docompletion(). But this method did not really
worked for ~ and =.  After this patch leading ~ and = is not untokenized.
This allowed me to include the second hunk of Zefram's patch in article
241. After my patch the whole patch from Zefram can be applied ignoring the
rejected patch near line 2363.

4. GLOB_COMPLETE did not work in some cases properly:

% zsh -f 
% setopt autolist globcomplete 
% echo ~/$Z*<TAB>
% echo ~/$ARGC
zsh: do you wish to see all 101 possibilities? 

Some parts of the patch are not strictly bugfixes only cleanups.

The patch depends on my previous patch in article 250. It applies to the hzoli
releases only. For normal beta10 releases it can be merged by hand. The
rejection is in doexpansion. In my releases the postfork call is replaced by
an if (...) globlist(vl); and that's the reason for the rejection.  I'll try
to make a patch for normal beta10 if I have time.

Bye,

   Zoltan

*** 1.30	1995/07/24 09:38:31
--- Src/zle_tricky.c	1995/07/24 10:16:46
***************
*** 611,620 ****
  			if (n == 1)
  			    lst = COMP_EXPAND;
  		    }
! 	    } else /* if (*q != Tilde) Why was this test here? */
  		do {
! 		    /* An equivalent check for words not starting with `~'.
! 		       First check if there is a parameter expresiion. */
  		    for (; *q && *q != String; q++);
  		    if (*q == String && q[1] != Inpar && q[1] != Inbrack) {
  			if (*++q == Inbrace) {
--- 611,620 ----
  			if (n == 1)
  			    lst = COMP_EXPAND;
  		    }
! 	    }
! 	    if (lst == COMP_EXPAND_COMPLETE)
  		do {
! 		    /* check if there is a parameter expresiion. */
  		    for (; *q && *q != String; q++);
  		    if (*q == String && q[1] != Inpar && q[1] != Inbrack) {
  			if (*++q == Inbrace) {
***************
*** 713,719 ****
  		cs = ocs;
  		errflag = 0;
  
! 		for (p = s; *p; p++)
  		    if (itok(*p))
  			if (*p != String && *p != Qstring)
  			    *p = ztokens[*p - Pound];
--- 713,722 ----
  		cs = ocs;
  		errflag = 0;
  
! 		p = s;
! 		if (*p == Tilde || *p == Equals)
! 		    p++;
! 		for (; *p; p++)
  		    if (itok(*p))
  			if (*p != String && *p != Qstring)
  			    *p = ztokens[*p - Pound];
***************
*** 1146,1163 ****
  {
      LinkList vl = newlinklist();
      char *ss;
-     int ng = opts[NULLGLOB];
  
-     opts[NULLGLOB] = OPT_SET;
-     lexsave();
-     s = dupstring(s);
      pushheap();
!     addlinknode(vl, s);
      prefork(vl, 0);
      if (errflag)
  	goto end;
!     if ((lst == COMP_LIST_EXPAND) || (lst == COMP_EXPAND))
  	globlist(vl);
      if (errflag)
  	goto end;
      if (empty(vl) || !*(char *)peekfirst(vl)) {
--- 1149,1168 ----
  {
      LinkList vl = newlinklist();
      char *ss;
  
      pushheap();
!     ss = dupstring(s);
!     addlinknode(vl, ss);
      prefork(vl, 0);
      if (errflag)
  	goto end;
!     if ((lst == COMP_LIST_EXPAND) || (lst == COMP_EXPAND)) {
! 	int ng = opts[NULLGLOB];
! 
! 	opts[NULLGLOB] = OPT_SET;
  	globlist(vl);
+ 	opts[NULLGLOB] = ng;
+     }
      if (errflag)
  	goto end;
      if (empty(vl) || !*(char *)peekfirst(vl)) {
***************
*** 1165,1171 ****
  	    feep();
  	goto end;
      }
!     if (peekfirst(vl) == (void *) s ||
  	       (!nextnode(firstnode(vl)) && *s == Tilde &&
  		(ss = dupstring(s), filesubstr(&ss, 0)) &&
  		!strcmp(ss, (char *)peekfirst(vl)))) {
--- 1170,1176 ----
  	    feep();
  	goto end;
      }
!     if (peekfirst(vl) == (void *) ss ||
  	       (!nextnode(firstnode(vl)) && *s == Tilde &&
  		(ss = dupstring(s), filesubstr(&ss, 0)) &&
  		!strcmp(ss, (char *)peekfirst(vl)))) {
***************
*** 1202,1210 ****
  	}
      }
    end:
-     opts[NULLGLOB] = ng;
      popheap();
-     lexrestore();
  }
  
  /* This is called from the lexer to give us word positions. */
--- 1207,1213 ----
***************
*** 2262,2279 ****
      }
      /* Do we have one of the special characters `~' and `=' at the
         beginning? */
!     switch (*s) {
!     case '~':
!     case Tilde:
! 	ic = Tilde;
! 	break;
!     case '=':
!     case Equals:
! 	ic = Equals;
! 	break;
!     default:
! 	ic = '\0';
!     }
  
      /* Check if we have to complete a parameter name... */
  
--- 2265,2272 ----
      }
      /* Do we have one of the special characters `~' and `=' at the
         beginning? */
!     if ((ic = *s) != Tilde && ic != Equals)
! 	ic = 0;
  
      /* Check if we have to complete a parameter name... */
  
***************
*** 2401,2407 ****
  
      noreal = !*delit;
      for (p = lpre; *p && *p != String && *p != Tick; p++);
!     tt = ic ? lpre + 1 : lpre;
      rpre = (*p || *lpre == Tilde || *lpre == Equals) ?
  	(noreal = 0, getreal(tt)) :
  	ztrdup(tt);
--- 2394,2400 ----
  
      noreal = !*delit;
      for (p = lpre; *p && *p != String && *p != Tick; p++);
!     tt = ic && !parampre ? lpre + 1 : lpre;
      rpre = (*p || *lpre == Tilde || *lpre == Equals) ?
  	(noreal = 0, getreal(tt)) :
  	ztrdup(tt);


                 reply	other threads:[~1995-07-24 10:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=9507241021.AA05677@turan.elte.hu \
    --to=hzoli@cs.elte.hu \
    --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).