zsh-workers
 help / color / mirror / code / Atom feed
* Completion problem
@ 1995-07-07  0:28 Zefram
  0 siblings, 0 replies; only message in thread
From: Zefram @ 1995-07-07  0:28 UTC (permalink / raw)
  To: Z Shell workers mailing list

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

There is still a major problem with some types of completion,
particularly noticeable with job completion.  (Try backgrounding
something in braces, then completing a fg or kill line.)  The
completion possibilities need to have metacharacters quoted the way
filenames already are.  A while ago I sent in a patch that added a -Q
flag to compctl, with this flag causing metacharacters to be quoted.
As that patch didn't get into the baseline, and no longer applies
cleanly, I'm producing a new version.

This patch, unlike the old one, changes the *default* completion
behaviour, as that is what is most useful.  It adds a -Q flag, but this
flag is used to *disable* the quoting, for the benefit of any
completion scripts that actually need this behaviour (I haven't seen
any).  If anyone is using my old patch, I'm afraid you will have to
reverse the sense of the -Q swith on your compctls to use this.

Richard, I hope you'll put this into the baseline, as it's a very
necessary improvement.  Currently a lot of completions are incapable of
handling metacharacters properly, and would be fixed by the use of this
patch.

 -zefram

      *** Doc/zshcompctl.1.old	Fri Jun 30 23:07:48 1995
      --- Doc/zshcompctl.1	Fri Jul  7 01:01:10 1995
      ***************
      *** 3,9 ****
        .SH NAME
        zshcompctl \- zsh programmable completion
        .SH DESCRIPTION
      ! \fBcompctl\fP [ \-\fBcfqovbCDTAIFpEjBaRGuderzNOZn\fP ] [ \-\fBk\fP \fIname\fP ]
        .br
        [ \-\fBX\fP \fIexplanation\fP ] [ \-\fBK\fP \fIfunction\fP ] 
        .br
      --- 3,9 ----
        .SH NAME
        zshcompctl \- zsh programmable completion
        .SH DESCRIPTION
      ! \fBcompctl\fP [ \-\fBQcfqovbCDTAIFpEjBaRGuderzNOZn\fP ] [ \-\fBk\fP \fIname\fP ]
        .br
        [ \-\fBX\fP \fIexplanation\fP ] [ \-\fBK\fP \fIfunction\fP ] 
        .br
      ***************
      *** 191,196 ****
      --- 191,207 ----
        lines. Only words matching \fIpattern\fP are taken. If \fInum\fP is
        zero or negative the whole history is searched and if \fIpattern\fP is
        the empty string (or \fB'*'\fP, of course) all words are taken.
      + .TP
      + \-\fBQ\fP
      + This flag combines with any normal \fBcompctl\fP option.  It instructs
      + the shell not to quote any metacharacters in the possible completions.
      + This allows, for example, a completion array (\-\fBk\fP) to complete
      + to a backquoted expression without actually executing the backquoted
      + command until the entire command is finally executed.
      + Normally metacharacters are automatically quoted, so that
      + user-defined completions don't need to do the required quoting,
      + which would be difficult to get right anyway,
      + especially when completing inside quotes.
        .TP
        \-\fBl\fP \fIcmd\fP
        This option can not be combined with any other option. If it is given
      *** Src/builtin.c.old	Fri Jul  7 00:46:50 1995
      --- Src/builtin.c	Fri Jul  7 00:52:59 1995
      ***************
      *** 1795,1800 ****
      --- 1795,1803 ----
        	    case 'n':
        		cct.mask |= CC_NAMED;
        		break;
      + 	    case 'Q':
      + 		cct.mask |= CC_QUOTEFLAG;
      + 		break;
        	    case 'k':
        		if ((*argv)[1]) {
        		    cct.keyvar = (*argv) + 1;
      ***************
      *** 2436,2442 ****
        printcompctl(char *s, Compctl cc)
        {
            Compctl cc2;
      !     char *css = "fcqovbAIFpEjrzBRGudeNOZUn";
            char *mss = " pcCwWsSnNmrR";
            unsigned long t = 0x7fffffff;
        
      --- 2439,2445 ----
        printcompctl(char *s, Compctl cc)
        {
            Compctl cc2;
      !     char *css = "fcqovbAIFpEjrzBRGudeNOZUnQ";
            char *mss = " pcCwWsSnNmrR";
            unsigned long t = 0x7fffffff;
        
      *** Src/zle_tricky.c.old	Fri Jul  7 00:47:01 1995
      --- Src/zle_tricky.c	Fri Jul  7 01:06:29 1995
      ***************
      *** 1488,1494 ****
        		untokenize(s = tt);
        	    }
        	}
      !     } else if (addwhat == -2 ||
        	       (addwhat == -3 && !(((Cmdnam) t)->flags & DISABLED)) ||
        	       (addwhat == -4 && (pm = (Param) t) &&
        		(PM_TYPE(pm->flags) == PM_SCALAR) &&
      --- 1488,1494 ----
        		untokenize(s = tt);
        	    }
        	}
      !     } else if (addwhat == -2 || addwhat == CC_QUOTEFLAG ||
        	       (addwhat == -3 && !(((Cmdnam) t)->flags & DISABLED)) ||
        	       (addwhat == -4 && (pm = (Param) t) &&
        		(PM_TYPE(pm->flags) == PM_SCALAR) &&
      ***************
      *** 1526,1531 ****
      --- 1526,1536 ----
        		test = !strcmp(e, lsuf);
        	    pl = lpl;
        	}
      + 	if (addwhat == CC_QUOTEFLAG) {
      + 	    te = s + pl;
      + 	    s = quotename(s, &e, &te, &pl);
      + 	    sl = strlen(s);
      + 	}
        	if (test)
        	    haswhat |= HAS_MISC;
            }
      ***************
      *** 2806,2812 ****
        	if (isset(AUTOCD) && isset(CDABLEVARS))
        	    dumphashtable(paramtab, -4);
            }
      !     addwhat = -2;
        
            if (cc->mask & CC_NAMED) {
        	/* Add named directories. */
      --- 2811,2817 ----
        	if (isset(AUTOCD) && isset(CDABLEVARS))
        	    dumphashtable(paramtab, -4);
            }
      !     addwhat = (cc->mask & CC_QUOTEFLAG) ? -2 : CC_QUOTEFLAG;
        
            if (cc->mask & CC_NAMED) {
        	/* Add named directories. */
      *** Src/zsh.h.old	Fri Jul  7 00:47:09 1995
      --- Src/zsh.h	Fri Jul  7 00:52:59 1995
      ***************
      *** 807,812 ****
      --- 807,813 ----
        #define CC_SPECIALS	(1<<22)
        #define CC_DELETE       (1<<23)
        #define CC_NAMED        (1<<24)
      + #define CC_QUOTEFLAG    (1<<25)
        
        #define CC_RESERVED     (1<<31)
        

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

iQBVAgUBL/x+n2WJ8JfKi+e9AQHmqwH7Bk5+kWEWI/DZlI0xtuc1rDSmAFnphCBZ
lT0pJuRgC5VYLKcqVUuV+XqWHqgOpxW8EY2apdYmKctOonaq2JJqEg==
=e1lg
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-07-07  0:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-07-07  0:28 Completion problem Zefram

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).