From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10188 invoked from network); 8 Aug 2001 07:19:38 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Aug 2001 07:19:38 -0000 Received: (qmail 8142 invoked by alias); 8 Aug 2001 07:19:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15597 Received: (qmail 8131 invoked from network); 8 Aug 2001 07:19:24 -0000 From: Sven Wischnowsky Date: Wed, 8 Aug 2001 09:19:05 +0200 (MET DST) Message-Id: <200108080719.JAA04358@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.dk Subject: Re: PATCH: new and updated completions In-Reply-To: <3B6FCB2A.32DFAAEA@u.genie.co.uk> Oliver Kiddle wrote: > ... > > I'd have thought it should be in _values itself as _values should > ideally be able to work with multiple words. Yes, here is the patch. It adds the -w option to _values which means that it will look at all words on the line. > This "easiest fix" isn't > going to handle explicit exclusion lists though. I'm not sure whether > there shouldn't be exclusions between bs and ibs/obs for dd but as the > exclusions don't work here, I didn't worry. You can now start to worry ;-) Bye Sven Index: Completion/Unix/Command/_dd =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_dd,v retrieving revision 1.3 diff -u -r1.3 _dd --- Completion/Unix/Command/_dd 2001/08/07 10:38:36 1.3 +++ Completion/Unix/Command/_dd 2001/08/08 07:19:00 @@ -2,21 +2,15 @@ local opts -opts=( - 'if[specify input file]:input file:_tilde_files' - 'of[specify output file]:output file:_tilde_files' - 'ibs[input block size]:block size (bytes)' - 'obs[output block size]:block size (bytes)' - 'bs[block size]:block size (bytes)' - 'cbs[conversion buffer size]:buffer size (bytes)' - 'skip[input blocks initially skipped]:blocks' - 'seek[output blocks initially skipped]:blocks' - 'files[specify number of input files to copy and concatenate]:number of files' - 'count[number of input blocks to copy]:blocks' +_values -w 'option' \ + 'if[specify input file]:input file:_tilde_files' \ + 'of[specify output file]:output file:_tilde_files' \ + 'ibs[input block size]:block size (bytes)' \ + 'obs[output block size]:block size (bytes)' \ + 'bs[block size]:block size (bytes)' \ + 'cbs[conversion buffer size]:buffer size (bytes)' \ + 'skip[input blocks initially skipped]:blocks' \ + 'seek[output blocks initially skipped]:blocks' \ + 'files[specify number of input files to copy and concatenate]:number of files' \ + 'count[number of input blocks to copy]:blocks' \ 'conv[specify conversions to apply]:conversion:_values -s , "conversion" ascii ebcdic ibm block unblock lcase ucase swab noerror sync' -) - -[[ "$PREFIX$SUFFIX" != *\=* ]] && - opts=( "${(@)opts:#(${(j:|:)~words[2,-1]%%\=*})\[*}" ) - -_values -S '=' 'option' "$opts[@]" Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.132 diff -u -r1.132 compsys.yo --- Doc/Zsh/compsys.yo 2001/08/06 15:56:23 1.132 +++ Doc/Zsh/compsys.yo 2001/08/08 07:19:03 @@ -3975,6 +3975,10 @@ Thus the values completed appear in the same word on the command line, unlike completion using tt(_arguments). +Normally, tt(_values) will only use the current word to determine +which values are already present on the command line. If the tt(-w) +option is given, the other arguments are used, too. + The first argument (after the options and separator character if they are given) is used as a string to print as a description before listing the values. Index: Src/Zle/computil.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v retrieving revision 1.71 diff -u -r1.71 computil.c --- Src/Zle/computil.c 2001/07/30 08:42:56 1.71 +++ Src/Zle/computil.c 2001/08/08 07:19:04 @@ -2499,6 +2499,7 @@ char **defs; /* original strings */ int ndefs; /* number of ... */ int lastt; /* last time used */ + int words; /* if to look at other words */ }; /* One value definition. */ @@ -2556,18 +2557,23 @@ Cvval val, *valp; Caarg arg; char **oargs = args, sep = '\0', asep = '=', *name, *descr, *p, *q, **xor, c; - int xnum, multi, vtype, hassep = 0; + int xnum, multi, vtype, hassep = 0, words = 0; - while (args[0][0] == '-' && (args[0][1] == 's' || args[0][1] == 'S') && + while (args[0][0] == '-' && + (args[0][1] == 's' || args[0][1] == 'S' || args[0][1] == 'w') && !args[0][2]) { if (args[0][1] == 's') { hassep = 1; sep = args[1][0]; - } else + args += 2; + } else if (args[0][1] == 'S') { asep = args[1][0]; - - args += 2; + args += 2; + } else { + words = 1; + args++; + } } if (!args[0] || !args[1]) { zwarnnam(nam, "not enough arguments", NULL, 0); @@ -2585,6 +2591,7 @@ ret->defs = zarrdup(oargs); ret->ndefs = arrlen(oargs); ret->lastt = time(0); + ret->words = words; for (valp = &(ret->vals); *args; args++) { int bs = 0; @@ -2892,6 +2899,35 @@ cv_alloced = 1; + if (d->words && compwords[0]) { + int i; + + for (i = 1; compwords[i]; i++) + if (i != compcurrent - 1) + for (str = compwords[i]; str && *str; ) { + if ((val = cv_next(d, &str, &arg))) { + zaddlinknode(state.vals, ztrdup(val->name)); + if (arg) { + char sav = '\0'; + + if (str) { + sav = str[-1]; + str[-1] = '\0'; + } + zaddlinknode(state.vals, ztrdup(arg)); + if (str) + str[-1] = sav; + } else + zaddlinknode(state.vals, ztrdup("")); + + if (i + 1 < compcurrent) + cv_inactive(d, val->xor); + } + } + + val = NULL; + arg = NULL; + } for (str = compprefix; str && *str; ) { if ((val = cv_next(d, &str, &arg))) { zaddlinknode(state.vals, ztrdup(val->name)); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de