summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Debian/_dpkg24
-rw-r--r--Doc/Zsh/compsys.yo11
-rw-r--r--Src/Zle/computil.c16
4 files changed, 42 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 89611286c..67cbab36f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2000-06-19 Sven Wischnowsky <wischnow@zsh.org>
+ * 11985: Completion/Debian/_dpkg, Doc/Zsh/compsys.yo, Src/Zle/computil.c:
+ _arguments: small fix for -s and new `!...' for things not to
+ complete (but to understand)
+
* 11982: Test/comptest: update comptest to not set ZLS_COLORS
directly
diff --git a/Completion/Debian/_dpkg b/Completion/Debian/_dpkg
index 75d8d0c18..abad50145 100644
--- a/Completion/Debian/_dpkg
+++ b/Completion/Debian/_dpkg
@@ -81,8 +81,10 @@ _dpkg_options=('--abort-after[abort after errors]:number of errors:' \
--{force,refuse,no-force}'--[forcing options]:what:(auto-select downgrade configure-any hold bad-path not-root overwrite overwrite-diverted depends-version depends confnew confold confdef confmiss conflicts architecture overwrite-dir remove-reinstreq remove-essential)')
_dpkg_options_recursive=('(--recursive)-R[recursive]' '(-R)--recursive')
-_dpkg_actions_install=('(--install)-i[install]' '(-i)--install')
-_dpkg_actions_record_avail=('(--record-avail)-A[record available]' '(-A)--record-avail')
+
+# not needed anymore?
+# _dpkg_actions_install=('(--install)-i[install]' '(-i)--install')
+# _dpkg_actions_record_avail=('(--record-avail)-A[record available]' '(-A)--record-avail')
case "${words[1]:t}" in
dpkg)
@@ -90,12 +92,12 @@ _arguments -C -s "$_dpkg_actions[@]" \
"$_dpkg_deb_actions[@]" \
"$_dpkg_common_actions[@]" \
"$_dpkg_options[@]" \
- "$_dpkg_options_recursive[@]"
+ "$_dpkg_options_recursive[@]" && return 0
;;
dpkg-deb)
_arguments "$_dpkg_deb_actions[@]" \
- "$_dpkg_common_actions[@]"
+ "$_dpkg_common_actions[@]" && return 0
;;
@@ -104,14 +106,16 @@ esac
case "$state" in
install|record_avail)
_funcall ret _dpkg_$state && return ret
- _arguments -C -s "$_dpkg_options[@]" \
- "${(@e):-\$_dpkg_actions_${state}}" \
+# not needed anymore?
+# "${(@e):-\$_dpkg_actions_${state}}" \
+ _arguments -C -A '-*' -s \
+ "$_dpkg_options[@]" \
+ \!${^_dpkg_actions%%:*} \
- recur \
- '(--recursive)-R[recursive]' \
- '(-R)--recursive' \
- ':directory:_files -/' \
+ "$_dpkg_options_recursive[@]" \
+ ':directory:_files -/' \
- nonrecur \
- ':Debian package:_files -g \*.deb'
+ ':Debian package:_files -g \*.deb'
;;
remove|purge|status|listfiles)
_funcall ret _dpkg_$state && return ret
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 71ceb9ab0..afba2eed3 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2800,6 +2800,17 @@ that the descriptions for all normal (non-option-) arguments should not be
used and a hyphen (tt(-)) to specify that the descriptions for all options
should not be used. This paragraph desperately needs rewriting.
+To simplify writing writing functions that call tt(_arguments) more
+than once, the var(specs) may also start with the character `tt(!)'
+(exclamation mark) to make the spec em(not) be completed. However, if
+this is used with one of the forms describing options, the option (and
+its arguments, if it takes any) will be understood and skipped if they
+appear on the command line. It's just that the option itself will not
+be completed. This is intended to be used with an array containing the
+options used in the first call to tt(arguments). The second call can
+then use `tt(\!${^global_options})' to ignore those options and
+complete only the ones understood in the current context.
+
In every case above, the var(action) determines how the possible
completions should be generated. In places where no sensible matches can
be generated, the action should consist of only a space. This will make
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index d65eaa5bf..da72a6902 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -325,6 +325,7 @@ struct caopt {
int active; /* still allowed on command line */
int num; /* it's the num'th option */
char *set; /* set name, shared */
+ int not; /* don't complete this option (`!...') */
};
#define CAO_NEXT 1
@@ -573,7 +574,7 @@ parse_cadef(char *nam, char **args)
char *adpre, *adsuf, *axor = NULL, *doset = NULL, **setp = NULL;
char *nonarg = NULL;
int single = 0, anum = 1, xnum, nopts, ndopts, nodopts, flags = 0;
- int state = 0;
+ int state = 0, not = 0;
nopts = ndopts = nodopts = 0;
@@ -683,6 +684,8 @@ parse_cadef(char *nam, char **args)
}
p = dupstring(*args);
xnum = 0;
+ if ((not = (*p == '!')))
+ p++;
if (*p == '(') {
/* There is a xor list, get it. */
@@ -910,6 +913,7 @@ parse_cadef(char *nam, char **args)
opt->type = otype;
opt->args = oargs;
opt->num = nopts++;
+ opt->not = not;
if (otype == CAO_DIRECT || otype == CAO_EQUAL)
ndopts++;
@@ -932,6 +936,9 @@ parse_cadef(char *nam, char **args)
int type = CAA_REST;
+ if (not)
+ continue;
+
if (*++p != ':') {
freecadef(all);
zwarnnam(nam, "invalid rest argument definition: %s", *args, 0);
@@ -957,6 +964,9 @@ parse_cadef(char *nam, char **args)
int type = CAA_NORMAL, direct;
Caarg arg, tmp, pre;
+ if (not)
+ continue;
+
if ((direct = idigit(*p))) {
/* Argment number is given. */
int num = 0;
@@ -1100,7 +1110,7 @@ ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp)
}
break;
}
- } else if (p && !p->active)
+ } else if (!p || (p && !p->active))
return NULL;
p = NULL;
}
@@ -1853,7 +1863,7 @@ bin_comparguments(char *nam, char **args, char *ops, int func)
(compcurrent == 1)))) {
ret = 0;
for (p = lstate->d->opts; p; p = p->next) {
- if (p->active) {
+ if (p->active && !p->not) {
switch (p->type) {
case CAO_NEXT: l = next; break;
case CAO_DIRECT: l = direct; break;