summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Core/_dispatch5
-rw-r--r--Completion/Base/Utility/_pick_variant2
-rw-r--r--Completion/compinit16
3 files changed, 20 insertions, 3 deletions
diff --git a/Completion/Base/Core/_dispatch b/Completion/Base/Core/_dispatch
index 87c81f899..3f6fe5b97 100644
--- a/Completion/Base/Core/_dispatch
+++ b/Completion/Base/Core/_dispatch
@@ -2,6 +2,7 @@
 
 local comp pat val name i ret=1 _compskip="$_compskip"
 local curcontext="$curcontext" service str noskip
+local -a match mbegin mend
 
 # If we get the option `-s', we don't reset `_compskip'.
 
@@ -24,6 +25,10 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
     [[ -n "$str" ]] || continue
     service="${_services[$str]:-$str}"
     for i in "${(@)_patcomps[(K)$str]}"; do
+      if [[ $i = (#b)"="([^=]#)"="(*) ]]; then
+	service=$match[1]
+	i=$match[2]
+      fi
       eval "$i" && ret=0
       if [[ "$_compskip" = *patterns* ]]; then
         break
diff --git a/Completion/Base/Utility/_pick_variant b/Completion/Base/Utility/_pick_variant
index 01fa2b98f..3bf848271 100644
--- a/Completion/Base/Utility/_pick_variant
+++ b/Completion/Base/Utility/_pick_variant
@@ -7,7 +7,7 @@ local -A opts
 (( $+_cmd_variant )) || typeset -gA _cmd_variant
 
 zparseopts -D -A opts c: r:
-: ${opts[-c]:=$words[1]}
+: ${opts[-c]:=${service:-$words[1]}}
 
 while [[ $1 = *=* ]]; do
   var+=( "${1%%\=*}" "${1#*=}" )
diff --git a/Completion/compinit b/Completion/compinit
index d85ff072e..aa42a12de 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -230,6 +230,10 @@ comppostfuncs=()
 
 compdef() {
   local opt autol type func delete new i ret=0 cmd svc
+  local -a match mbegin mend
+
+  emulate -L zsh
+  setopt extendedglob
 
   # Get the options.
 
@@ -364,10 +368,18 @@ compdef() {
         else
           case "$type" in
           pattern)
-            _patcomps[$1]="$func"
+	    if [[ $1 = (#b)(*)=(*) ]]; then
+	      _patcomps[$match[1]]="=$match[2]=$func"
+	    else
+	      _patcomps[$1]="$func"
+	    fi
             ;;
           postpattern)
-            _postpatcomps[$1]="$func"
+	    if [[ $1 = (#b)(*)=(*) ]]; then
+	      _postpatcomps[$match[1]]="=$match[2]=$func"
+	    else
+	      _postpatcomps[$1]="$func"
+	    fi
             ;;
           *)
             if [[ "$1" = *\=* ]]; then