mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-03 20:20:56 +02:00
manual/10204
This commit is contained in:
parent
e955563c02
commit
c9e0760f68
6 changed files with 58 additions and 35 deletions
|
@ -236,14 +236,17 @@ if (( $# )) && comparguments -i "$autod" "$@"; then
|
||||||
|
|
||||||
# A string in braces is evaluated.
|
# A string in braces is evaluated.
|
||||||
|
|
||||||
_loop arguments expl "$descr" eval "$action[2,-2]"
|
while _try arguments expl "$descr"; do
|
||||||
|
eval "$action[2,-2]"
|
||||||
|
done
|
||||||
elif [[ "$action" = \ * ]]; then
|
elif [[ "$action" = \ * ]]; then
|
||||||
|
|
||||||
# If the action starts with a space, we just call it.
|
# If the action starts with a space, we just call it.
|
||||||
|
|
||||||
eval "action=( $action )"
|
eval "action=( $action )"
|
||||||
_loop arguments expl "$descr" "$action[@]"
|
while _try arguments expl "$descr"; do
|
||||||
|
"$action[@]"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
|
|
||||||
# Otherwise we call it with the description-arguments.
|
# Otherwise we call it with the description-arguments.
|
||||||
|
|
|
@ -124,14 +124,17 @@ if compvalues -i "$@"; then
|
||||||
|
|
||||||
# A string in braces is evaluated.
|
# A string in braces is evaluated.
|
||||||
|
|
||||||
_loop arguments expl "$descr" eval "$action[2,-2]"
|
while _try arguments expl "$descr"; do
|
||||||
|
eval "$action[2,-2]"
|
||||||
|
done
|
||||||
elif [[ "$action" = \ * ]]; then
|
elif [[ "$action" = \ * ]]; then
|
||||||
|
|
||||||
# If the action starts with a space, we just call it.
|
# If the action starts with a space, we just call it.
|
||||||
|
|
||||||
eval "action=( $action )"
|
eval "action=( $action )"
|
||||||
_loop arguments expl "$descr" "$action[@]"
|
while _try arguments expl "$descr"; do
|
||||||
|
"$action[@]"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
|
|
||||||
# Otherwise we call it with the description-arguments built above.
|
# Otherwise we call it with the description-arguments built above.
|
||||||
|
|
|
@ -50,13 +50,17 @@ while _tags; do
|
||||||
|
|
||||||
# A string in braces is evaluated.
|
# A string in braces is evaluated.
|
||||||
|
|
||||||
_loop "${def%%:*}" expl "$descr" eval "$action[2,-2]"
|
while _try "${def%%:*}" expl "$descr"; do
|
||||||
|
eval "$action[2,-2]"
|
||||||
|
done
|
||||||
elif [[ "$action" = \ * ]]; then
|
elif [[ "$action" = \ * ]]; then
|
||||||
|
|
||||||
# If the action starts with a space, we just call it.
|
# If the action starts with a space, we just call it.
|
||||||
|
|
||||||
eval "action=( $action )"
|
eval "action=( $action )"
|
||||||
_loop "${def%%:*}" expl "$descr" "$action[@]"
|
while _try "${def%%:*}" expl "$descr"; do
|
||||||
|
"$action[@]"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
|
|
||||||
# Otherwise we call it with the description-arguments built above.
|
# Otherwise we call it with the description-arguments built above.
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
#autoload
|
#autoload
|
||||||
|
|
||||||
|
local prev
|
||||||
|
|
||||||
|
# A `--' as the first argument says that we should tell comptags to use
|
||||||
|
# the preceding function nesting level. This is only documented here because
|
||||||
|
# if everythings goes well, users won't have to worry about it and should
|
||||||
|
# not mess with it.
|
||||||
|
|
||||||
|
if [[ "$1" = -- ]]; then
|
||||||
|
prev=-
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
if (( $# )); then
|
if (( $# )); then
|
||||||
|
|
||||||
# We have arguments: the tags supported in this context.
|
# We have arguments: the tags supported in this context.
|
||||||
|
@ -33,7 +45,7 @@ if (( $# )); then
|
||||||
|
|
||||||
# Set and remember offered tags.
|
# Set and remember offered tags.
|
||||||
|
|
||||||
comptags -i "$curcontext" "$@"
|
comptags "-i$prev" "$curcontext" "$@"
|
||||||
|
|
||||||
# Sort the tags.
|
# Sort the tags.
|
||||||
|
|
||||||
|
@ -80,11 +92,11 @@ if (( $# )); then
|
||||||
|
|
||||||
# Return non-zero if at least one set of tags should be used.
|
# Return non-zero if at least one set of tags should be used.
|
||||||
|
|
||||||
comptags -T
|
comptags "-T$prev"
|
||||||
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The other mode: switch to the next set of tags.
|
# The other mode: switch to the next set of tags.
|
||||||
|
|
||||||
comptags -N
|
comptags "-N$prev"
|
||||||
|
|
|
@ -26,8 +26,8 @@ if [[ $# -gt 3 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
elif [[ $# -gt 1 ]]; then
|
elif [[ $# -gt 1 ]]; then
|
||||||
_tags "$targs[@]" "$1" && _comp_tags="$_comp_tags $1" &&
|
_tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1" &&
|
||||||
_description "$gopt" "$@"
|
_description "$gopt" "$@"
|
||||||
else
|
else
|
||||||
_tags "$targs[@]" "$1" && _comp_tags="$_comp_tags $1"
|
_tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2225,14 +2225,14 @@ freectags(Ctags t)
|
||||||
/* Set the tags for the current local level. */
|
/* Set the tags for the current local level. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
settags(char **tags)
|
settags(int level, char **tags)
|
||||||
{
|
{
|
||||||
Ctags t;
|
Ctags t;
|
||||||
|
|
||||||
if (comptags[locallevel])
|
if (comptags[level])
|
||||||
freectags(comptags[locallevel]);
|
freectags(comptags[level]);
|
||||||
|
|
||||||
comptags[locallevel] = t = (Ctags) zalloc(sizeof(*t));
|
comptags[level] = t = (Ctags) zalloc(sizeof(*t));
|
||||||
|
|
||||||
t->all = zarrdup(tags + 1);
|
t->all = zarrdup(tags + 1);
|
||||||
t->context = ztrdup(*tags);
|
t->context = ztrdup(*tags);
|
||||||
|
@ -2263,22 +2263,23 @@ arrcontains(char **a, char *s, int colon)
|
||||||
static int
|
static int
|
||||||
bin_comptags(char *nam, char **args, char *ops, int func)
|
bin_comptags(char *nam, char **args, char *ops, int func)
|
||||||
{
|
{
|
||||||
int min, max, n;
|
int min, max, n, level;
|
||||||
|
|
||||||
if (incompfunc != 1) {
|
if (incompfunc != 1) {
|
||||||
zwarnnam(nam, "can only be called from completion function", NULL, 0);
|
zwarnnam(nam, "can only be called from completion function", NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (args[0][0] != '-' || !args[0][1] || args[0][2]) {
|
if (args[0][0] != '-' || !args[0][1] ||
|
||||||
|
(args[0][2] && (args[0][2] != '-' || args[0][3]))) {
|
||||||
zwarnnam(nam, "invalid argument: %s", args[0], 0);
|
zwarnnam(nam, "invalid argument: %s", args[0], 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (locallevel >= MAX_TAGS) {
|
level = locallevel - (args[0][2] ? 1 : 0);
|
||||||
|
if (level >= MAX_TAGS) {
|
||||||
zwarnnam(nam, "nesting level too deep", NULL, 0);
|
zwarnnam(nam, "nesting level too deep", NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if ((args[0][1] != 'i' && args[0][1] != 'A' && !comptags[locallevel]) ||
|
if (args[0][1] != 'i' && args[0][1] != 'I' && !comptags[level]) {
|
||||||
(args[0][1] == 'A' && !comptags[lasttaglevel])) {
|
|
||||||
zwarnnam(nam, "no tags registered", NULL, 0);
|
zwarnnam(nam, "no tags registered", NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -2304,39 +2305,39 @@ bin_comptags(char *nam, char **args, char *ops, int func)
|
||||||
}
|
}
|
||||||
switch (args[0][1]) {
|
switch (args[0][1]) {
|
||||||
case 'i':
|
case 'i':
|
||||||
settags(args + 1);
|
settags(level, args + 1);
|
||||||
lasttaglevel = locallevel;
|
lasttaglevel = level;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
setsparam(args[1], ztrdup(comptags[locallevel]->context));
|
setsparam(args[1], ztrdup(comptags[level]->context));
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
return !comptags[locallevel]->sets;
|
return !comptags[level]->sets;
|
||||||
case 'N':
|
case 'N':
|
||||||
{
|
{
|
||||||
Ctset s;
|
Ctset s;
|
||||||
|
|
||||||
if (comptags[locallevel]->init)
|
if (comptags[level]->init)
|
||||||
comptags[locallevel]->init = 0;
|
comptags[level]->init = 0;
|
||||||
else if ((s = comptags[locallevel]->sets)) {
|
else if ((s = comptags[level]->sets)) {
|
||||||
comptags[locallevel]->sets = s->next;
|
comptags[level]->sets = s->next;
|
||||||
s->next = NULL;
|
s->next = NULL;
|
||||||
freectset(s);
|
freectset(s);
|
||||||
}
|
}
|
||||||
return !comptags[locallevel]->sets;
|
return !comptags[level]->sets;
|
||||||
}
|
}
|
||||||
case 'R':
|
case 'R':
|
||||||
{
|
{
|
||||||
Ctset s;
|
Ctset s;
|
||||||
|
|
||||||
return !((s = comptags[locallevel]->sets) &&
|
return !((s = comptags[level]->sets) &&
|
||||||
arrcontains(s->tags, args[1], 1));
|
arrcontains(s->tags, args[1], 1));
|
||||||
}
|
}
|
||||||
case 'A':
|
case 'A':
|
||||||
{
|
{
|
||||||
Ctset s;
|
Ctset s;
|
||||||
|
|
||||||
if (comptags[lasttaglevel] && (s = comptags[lasttaglevel]->sets)) {
|
if (comptags[level] && (s = comptags[level]->sets)) {
|
||||||
char **q, *v = NULL;
|
char **q, *v = NULL;
|
||||||
int l = strlen(args[1]);
|
int l = strlen(args[1]);
|
||||||
|
|
||||||
|
@ -2368,10 +2369,10 @@ bin_comptags(char *nam, char **args, char *ops, int func)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case 'S':
|
case 'S':
|
||||||
if (comptags[locallevel]->sets) {
|
if (comptags[level]->sets) {
|
||||||
char **ret;
|
char **ret;
|
||||||
|
|
||||||
ret = zarrdup(comptags[locallevel]->sets->tags);
|
ret = zarrdup(comptags[level]->sets->tags);
|
||||||
setaparam(args[1], ret);
|
setaparam(args[1], ret);
|
||||||
} else
|
} else
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue