summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Unix/Command/_dd28
-rw-r--r--Doc/Zsh/compsys.yo4
-rw-r--r--Src/Zle/computil.c46
4 files changed, 62 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 699529b0f..5ba4a33f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-08 Sven Wischnowsky <wischnow@zsh.org>
+
+ * 15597: Completion/Unix/Command/_dd, Doc/Zsh/compsys.yo,
+ Src/Zle/computil.c: follow-up to 15588; add -w option to
+ _values (look at all words); change _dd back
+
2001-08-07 Wayne Davison <wayned@users.sourceforge.net>
* users/4092: Src/hist.c: Don't lose the last history line
diff --git a/Completion/Unix/Command/_dd b/Completion/Unix/Command/_dd
index 64b8275e8..0c950f047 100644
--- a/Completion/Unix/Command/_dd
+++ b/Completion/Unix/Command/_dd
@@ -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[@]"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 6314fa2e5..ddfe59368 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3975,6 +3975,10 @@ next argument is used as the character that separates multiple values.
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.
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 12fafc71d..d1bd0aac1 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2499,6 +2499,7 @@ struct cvdef {
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 @@ parse_cvdef(char *nam, char **args)
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 @@ parse_cvdef(char *nam, char **args)
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_parse_word(Cvdef d)
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));