about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-17 10:59:46 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-17 10:59:46 +0000
commit0e3f4cecde90d9c07bfae1a9d522b285bcc8d6a3 (patch)
treefcd47ed650a154650b9c11111338fed7ab22932e /Completion/Core
parentf82d790d908588684a9f19ace5523a033f0cde99 (diff)
downloadzsh-0e3f4cecde90d9c07bfae1a9d522b285bcc8d6a3.tar.gz
zsh-0e3f4cecde90d9c07bfae1a9d522b285bcc8d6a3.tar.xz
zsh-0e3f4cecde90d9c07bfae1a9d522b285bcc8d6a3.zip
zsh-workers/9772
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_approximate9
-rw-r--r--Completion/Core/_description2
-rw-r--r--Completion/Core/_expand2
-rw-r--r--Completion/Core/_list2
-rw-r--r--Completion/Core/_main_complete27
-rw-r--r--Completion/Core/_match2
-rw-r--r--Completion/Core/_menu2
-rw-r--r--Completion/Core/_oldlist2
-rw-r--r--Completion/Core/_prefix10
9 files changed, 36 insertions, 22 deletions
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index ac2b69aad..6c7ae5d77 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -5,12 +5,13 @@
 # shown in a list and one can cycle through them as in a menucompletion
 # or get the corrected prefix.
 
-local _comp_correct _correct_expl comax cfgacc
-local curcontext="${curcontext}" oldcontext opm="$compstate[pattern_match]"
+# We don't try correction if the string is too short or we have tried it
+# already.
 
-# We don't try correction if the string is too short.
+[[ _matcher_num -gt 1 || "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
 
-[[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
+local _comp_correct _correct_expl comax cfgacc
+local curcontext="${curcontext}" oldcontext opm="$compstate[pattern_match]"
 
 [[ "$curcontext" != [^:]#:correct:* ]] &&
     curcontext="${curcontext/:[^:]#:/:approximate:}"
diff --git a/Completion/Core/_description b/Completion/Core/_description
index 970ee8f6a..6326d1f03 100644
--- a/Completion/Core/_description
+++ b/Completion/Core/_description
@@ -27,7 +27,7 @@ zstyle -s ":completion:${curcontext}:$1" group-name gname &&
     [[ -z "$gname" ]] && gname="$1"
 zstyle -s ":completion:${curcontext}:$1" matcher match &&
     opts=($opts -M "${(q)match}")
-[[ -n "$_comp_matcher" ]] && opts=($opts -M "${(q)_comp_matcher}")
+[[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}")
 
 if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
   opts=( $opts -F _comp_ignore)
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index 2bb7d4fb3..8279a1406 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -7,6 +7,8 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
+[[ _matcher_num -gt 1 ]] && return 1
+
 local exp word="$PREFIX$SUFFIX" sort expr expl subd suf=" "
 local curcontext="${curcontext/:[^:]#:/:expand:}"
 
diff --git a/Completion/Core/_list b/Completion/Core/_list
index 597d173ad..ea85ca13d 100644
--- a/Completion/Core/_list
+++ b/Completion/Core/_list
@@ -4,6 +4,8 @@
 # insert possible completions only after the list has been shown at
 # least once.
 
+[[ _matcher_num -gt 1 ]] && return 1
+
 local pre suf expr curcontext="${curcontext/:[^:]#:/:list:}"
 
 # Get the strings to compare.
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 3f71e2554..dc546d763 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -20,7 +20,8 @@ setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local comp post ret=1 _compskip format _comp_ignore \
-      _completers _completers_left _comp_matcher \
+      _completers _completer _completer_num \
+      _matchers _matcher _matcher_num \
       context state line opt_args val_args curcontext="$curcontext" \
       _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
       _saved_exact="${compstate[exact]}" \
@@ -62,14 +63,22 @@ _last_menu_style=()
 # And now just call the completer functions defined.
 
 _completers=( "$@" )
-_completers_left=( "$@" )
-
-for comp; do
-  if "$comp"; then
-    ret=0
-    break;
-  fi
-  shift 1 _completers_left
+_completer_num=1
+
+for _completer; do
+  _matcher="${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}"
+  zstyle -a ":completion:${curcontext/::/:${_matcher}:}:" matcher-list _matchers ||
+      _matchers=( '' )
+
+  _matcher_num=1
+  for _matcher in "$_matchers[@]"; do
+    if "$_completer"; then
+      ret=0
+      break 2
+    fi
+    (( _matcher_num++ ))
+  done
+  (( _completer_num++ ))
 done
 
 if [[ $compstate[nmatches] -gt 1 ]]; then
diff --git a/Completion/Core/_match b/Completion/Core/_match
index ad481f23b..5dc7936bc 100644
--- a/Completion/Core/_match
+++ b/Completion/Core/_match
@@ -9,6 +9,8 @@
 # expand-or-complete function because otherwise the pattern will
 # be expanded using globbing.
 
+[[ _matcher_num -gt 1 ]] && return 1
+
 local tmp opm="$compstate[pattern_match]" ret=0 orig ins
 local curcontext="${curcontext/:[^:]#:/:match:}"
 
diff --git a/Completion/Core/_menu b/Completion/Core/_menu
index 5ec1a1a55..6528fc542 100644
--- a/Completion/Core/_menu
+++ b/Completion/Core/_menu
@@ -1,5 +1,7 @@
 #autoload
 
+[[ _matcher_num -gt 1 ]] && return 1
+
 local curcontext="${curcontext/:[^:]#:/:menu:}"
 
 # This completer is an example showing how menucompletion can be
diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist
index 450e3cb29..74e48d6e0 100644
--- a/Completion/Core/_oldlist
+++ b/Completion/Core/_oldlist
@@ -1,5 +1,7 @@
 #autoload
 
+[[ _matcher_num -gt 1 ]] && return 1
+
 local curcontext="${curcontext/:[^:]#:/:oldlist:}" list
 
 zstyle -s ":completion:${curcontext}:" list list
diff --git a/Completion/Core/_prefix b/Completion/Core/_prefix
index 34decf425..ed95140bd 100644
--- a/Completion/Core/_prefix
+++ b/Completion/Core/_prefix
@@ -4,10 +4,10 @@
 
 [[ -n "$SUFFIX" ]] || return 1
 
-local curcontext="${curcontext/:[^:]#:/:prefix-${(M)#${(@)_completers[1,-$#_completers_left]}:#_prefix}:}" comp i
+local curcontext="${curcontext/:[^:]#:/:prefix-${(M)#_completers[1,_completer_num]:#_prefix}:}" comp i
 
 zstyle -a ":completion:${curcontext}:" completer comp ||
-  comp=( "${(@)_completers[1,-${#_completers_left}-1][(R)_prefix,-1]}" )
+  comp=( "${(@)_completers[1,_completer_num][(R)_prefix,-1]}" )
 
 if zstyle -t ":completion:${curcontext}:" add-space; then
   ISUFFIX=" $SUFFIX"
@@ -16,14 +16,8 @@ else
 fi
 SUFFIX=''
 
-local _completers _completer_left
-
-_completers=( "$comp[@]" )
-_completers_left=( "$comp[@]" )
-
 for i in "$comp[@]"; do
   [[ "$i" != _prefix ]] && "$i" && return 0
-  shift 1 _completers_left
 done
 
 return 1