mirror of
https://github.com/zsh-users/zsh
synced 2024-09-16 06:30:26 +00:00
follow-up to 15588; add -w option to _values (look at all words); change _dd back (15597)
This commit is contained in:
parent
0c08265c73
commit
7e23143359
|
@ -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
|
||||
|
|
|
@ -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[@]"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue