Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Completion on =



-----BEGIN PGP SIGNED MESSAGE-----

The patch below fixes a couple of problems with filename completion on
~ and =.  Previously these characters were treated specially for
completion even if quoted.  Also, completion on = did not include
aliases, which are actually subject to = substitution.

Can someone tell me why

% echo =<TAB>

takes a good minute or so (here) to ask me if I want to see a list of
3000 matches, but

% compctl -Dx 's[@]' -ca -- + -f
% echo @<TAB>

takes under two seconds?

 -zefram

      *** 1.2	1995/07/19 06:24:40
      --- zle_tricky.c	1995/07/19 07:16:24
      ***************
      *** 1406,1412 ****
            /* addwhat: -5 is for files, -6 is for glob expansions, -8 is for
               executable files (e.g. command paths), -7 is for command names (from
               cmdnamtab) and -1 is for other file specifications (things with
      !        `~' of `=' at the beginning, ...). */
            else if (addwhat == -1 || addwhat == -5 || addwhat == -6 ||
        	     addwhat == CC_FILES || addwhat == -7 || addwhat == -8) {
        	if (sl < fpl + fsl)
      --- 1406,1413 ----
            /* addwhat: -5 is for files, -6 is for glob expansions, -8 is for
               executable files (e.g. command paths), -7 is for command names (from
               cmdnamtab) and -1 is for other file specifications (things with
      !        `~' of `=' at the beginning, ...).  -3 is for executable command names.
      !     */
            else if (addwhat == -1 || addwhat == -5 || addwhat == -6 ||
        	     addwhat == CC_FILES || addwhat == -7 || addwhat == -8) {
        	if (sl < fpl + fsl)
      ***************
      *** 2357,2363 ****
            /* Do we have one of the special characters `~' and `=' at the
               beginning? */
            if ((ic = *s) != Tilde && ic != Equals)
      ! 	ic = (*s == '~' ? Tilde : (*s == '=' ? Equals : '\0'));
            /* Re-adjust the offs variable after all the changes we might have done
               to s, cs, and wb. */
            if ((offs = cs - wb) > (t = strlen(s)))
      --- 2358,2364 ----
            /* Do we have one of the special characters `~' and `=' at the
               beginning? */
            if ((ic = *s) != Tilde && ic != Equals)
      ! 	ic = 0;
            /* Re-adjust the offs variable after all the changes we might have done
               to s, cs, and wb. */
            if ((offs = cs - wb) > (t = strlen(s)))
      ***************
      *** 2473,2483 ****
            }
            lsuf = ztrdup(s + offs);
        
      !     /* First check for ~... and =.... */
      ! 
      !     if (ic) {
      ! 	/* It is one of these, so search backward to see if there is a slash.
      ! 	   If there is one, we have to do normal file completion. */
        	for (p = lpre + strlen(lpre); p > lpre; p--)
        	    if (*p == '/')
        		break;
      --- 2474,2481 ----
            }
            lsuf = ztrdup(s + offs);
        
      !     /* First check for ~.../... */
      !     if (ic == Tilde) {
        	for (p = lpre + strlen(lpre); p > lpre; p--)
        	    if (*p == '/')
        		break;
      ***************
      *** 2485,2492 ****
        	if (*p == '/')
        	    ic = 0;
            }
      -     /* Compute real prefix/suffix. */
        
            noreal = !*delit;
            for (p = lpre; *p && *p != String && *p != Tick; p++);
            tt = ic ? lpre + 1 : lpre;
      --- 2483,2490 ----
        	if (*p == '/')
        	    ic = 0;
            }
        
      +     /* Compute real prefix/suffix. */
            noreal = !*delit;
            for (p = lpre; *p && *p != String && *p != Tick; p++);
            tt = ic ? lpre + 1 : lpre;
      ***************
      *** 2605,2614 ****
        	    maketildelist();
        	else if (ic == Equals) {
        	    /* Completion after `=', get the command names from the
      ! 	       cmdnamtab. */
        	    if (isset(HASHLISTALL))
        		fullhash();
        	    dumphashtable(cmdnamtab, -7);
        	} else {
        	    /* Normal file completion... */
        	    if (ispattern & 1) {
      --- 2603,2613 ----
        	    maketildelist();
        	else if (ic == Equals) {
        	    /* Completion after `=', get the command names from the
      ! 	       cmdnamtab and aliases from aliastab. */
        	    if (isset(HASHLISTALL))
        		fullhash();
        	    dumphashtable(cmdnamtab, -7);
      + 	    dumphashtable(aliastab, -2);
        	} else {
        	    /* Normal file completion... */
        	    if (ispattern & 1) {
      ***************
      *** 2770,2776 ****
        	}
            }
            /* Use tricat() instead of dyncat() to get zalloc()'d memory. */
      !     if (ic == Tilde || ic == Equals) {
        	/* Now change the `~' and `=' tokens to the real characters
        	   so that things starting with these characters will be added. */
        	char *orpre = rpre;
      --- 2769,2775 ----
        	}
            }
            /* Use tricat() instead of dyncat() to get zalloc()'d memory. */
      !     if (ic) {
        	/* Now change the `~' and `=' tokens to the real characters
        	   so that things starting with these characters will be added. */
        	char *orpre = rpre;

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBMAy1UGWJ8JfKi+e9AQGeGQH/cmsTS5R6lu2R2PGLVoGD6Q5wELaJbves
RqlTIrDquSmjIE/uPpyDbbCMS1N440ATNsL7uteDKfDk44aUvaYq2w==
=xjiw
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author