1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-09 16:56:04 +02:00

add new sepcial context -assign-parameter- for completing the parameter in an assignment (17387)

This commit is contained in:
Sven Wischnowsky 2002-07-01 08:25:15 +00:00
parent 6278159f6d
commit 053629183d
8 changed files with 43 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2002-07-01 Sven Wischnowsky <wischnow@zsh.org>
* 17387: Completion/Zsh/Context/.distfiles,
Completion/Zsh/Context/_assign, Doc/Zsh/compsys.yo,
Doc/Zsh/compwid.yo, Src/zsh.h, Src/Zle/compcore.c,
Src/Zle/zle_tricky.c: add new sepcial context
-assign-parameter- for completing the parameter in an
assignment
2002-06-26 Bart Schaefer <schaefer@zsh.org>
* 17357: Src/mkbltnmlst.sh: predefine autoloads for zsh emulation

View File

@ -1,6 +1,6 @@
DISTFILES_SRC='
.distfiles
_autocd
_assign _autocd
_brace_parameter _equal _math _subscript
_condition _first _parameter _tilde
_default _in_vared _redirect _value

View File

@ -0,0 +1,3 @@
#compdef -assign-parameter-
_parameters -g "^*readonly*" -S ''

View File

@ -2515,6 +2515,10 @@ item(tt(-brace-parameter-))(
for completing the name of a parameter expansion within braces
(`tt(${...})').
)
kindex(-assign-parameter-, completion context)
item(tt(-assign-parameter-))(
for completing the name of a parameter in an assignment.
)
kindex(-command-, completion context)
item(tt(-command-))(
for completing in a command position.

View File

@ -158,6 +158,9 @@ item(tt(brace_parameter))(
when completing the name of a parameter in a parameter expansion beginning
with tt(${).
)
item(tt(assign_parameter))(
when completing the name of a parameter in a parameter assignment.
)
item(tt(command))(
when completing for a normal command (either in command position or for
an argument of the command).

View File

@ -553,6 +553,8 @@ callcompfunc(char *s, char *fn)
compparameter = compredirect = "";
if (ispar)
compcontext = (ispar == 2 ? "brace_parameter" : "parameter");
else if (linwhat == IN_PAR)
compcontext = "assign_parameter";
else if (linwhat == IN_MATH) {
if (insubscr) {
compcontext = "subscript";

View File

@ -1256,12 +1256,25 @@ get_comp_string(void)
insubscr = 2;
else
insubscr = 1;
} else if (*s == '=' && cs > wb + (s - tt)) {
s++;
wb += s - tt;
t0 = STRING;
s = ztrdup(s);
inwhat = IN_ENV;
} else if (*s == '=') {
if (cs > wb + (s - tt)) {
s++;
wb += s - tt;
s = ztrdup(s);
inwhat = IN_ENV;
} else {
char *p = s;
if (p[-1] == '+')
p--;
sav = *p;
*p = '\0';
inwhat = IN_PAR;
s = ztrdup(tt);
*p = sav;
we = wb + p - tt;
}
t0 = STRING;
}
lincmd = 1;
}

View File

@ -1318,6 +1318,8 @@ struct histent {
#define IN_COND 3
/* In a parameter assignment (e.g. `foo=bar'). */
#define IN_ENV 4
/* In a parameter name in an assignment. */
#define IN_PAR 5
/******************************/