summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Core/_main_complete24
-rw-r--r--Doc/Zsh/compsys.yo6
3 files changed, 29 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 02d1dd253..1e21e0d3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2000-05-18 Sven Wischnowsky <wischnow@zsh.org>
+ * 11459: Completion/Core/_main_complete, Doc/Zsh/compsys.yo: allow
+ _main_complete to call an arbitrary command given as arguments
+
* 11457: Doc/Zsh/compsys.yo, Src/Zle/compctl.mdd: small doc fix;
make compcall autoload compctl module
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 03fb15f31..a67e57db6 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -20,7 +20,7 @@ setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset ksharrays
exec </dev/null # ZLE closes stdin, which can cause errors
-local func funcs ret=1 tmp _compskip format nm \
+local func funcs ret=1 tmp _compskip format nm call \
_completers _completer _completer_num curtag _comp_force_list \
_matchers _matcher _matcher_num _comp_tags _comp_mesg \
context state line opt_args val_args curcontext="$curcontext" \
@@ -84,7 +84,16 @@ fi
# Get the names of the completers to use in the positional parameters.
if (( $# )); then
- _completers=( "$@" )
+ if [[ "$1" = - ]]; then
+ if [[ $# -lt 3 ]]; then
+ _completers=()
+ else
+ _completers=( "$2" )
+ call=yes
+ fi
+ else
+ _completers=( "$@" )
+ fi
else
zstyle -a ":completion:${curcontext}:" completer _completers ||
_completers=( _complete _ignored )
@@ -104,7 +113,9 @@ done
for tmp in "$_completers[@]"; do
- if [[ "$tmp" = *:-* ]]; then
+ if [[ -n "$call" ]]; then
+ _completer="${tmp}"
+ elif [[ "$tmp" = *:-* ]]; then
_completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}"
tmp="${tmp%:*}"
elif [[ $tmp = *:* ]]; then
@@ -120,7 +131,12 @@ for tmp in "$_completers[@]"; do
_matcher_num=1
for _matcher in "$_matchers[@]"; do
- if "$tmp"; then
+ if [[ -n "$call" ]]; then
+ if "${(@)argv[3,-1]}"; then
+ ret=0
+ break 2
+ fi
+ elif "$tmp"; then
ret=0
break 2
fi
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 1638e5406..ddd815c4a 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2003,6 +2003,12 @@ functions to decide if other completers should be called. If the return
value is zero, no other completers are tried and the tt(_main_complete)
function returns.
+If the first argument to tt(_main_complete) is a single hyphen, the
+arguments will not be taken as names of completers. Instead, the
+second argument gives a name to use in the var(completer) field of the
+context and the other arguments give a command anme and arguments to
+call to generate the matches.
+
The following completer functions are contained in the distribution (users
may write their own):