summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/_arguments2
-rw-r--r--Completion/Core/_complete13
-rw-r--r--Doc/Zsh/compsys.yo9
4 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 95ba5c2a8..231256fc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2000-08-02  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 12483: Completion/Base/_arguments, Completion/Core/_complete,
+ 	Doc/Zsh/compsys.yo: if compcontext is an assoc, the keys are the
+ 	completions and the values are their descriptions
+	
 	* 12475: Completion/Base/_arguments: prefer user-defined specs
  	over ones derived from --help output
 	
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index 5a8da45ab..68a7ba848 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -78,7 +78,7 @@ if (( long )); then
 
       # Using (( ... )) gives a parse error.
 
-      let "$tmpargv[(I)(|\([^\)]#\))${opt}(|[-+=])(|\[*\])(|:*)]" ||
+      let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+=])(|\[*\])(|:*)]" ||
           tmp=( "$tmp[@]" "$opt" )
     done
     lopts=( "$tmp[@]" )
diff --git a/Completion/Core/_complete b/Completion/Core/_complete
index 2441771bc..809df1fa9 100644
--- a/Completion/Core/_complete
+++ b/Completion/Core/_complete
@@ -13,11 +13,22 @@ oldcontext="$curcontext"
 
 if [[ -n "$compcontext" ]]; then
 
-  if [[ "${(t)compcontext}" = *(array|assoc)* ]]; then
+  if [[ "${(t)compcontext}" = *array* ]]; then
     local expl
 
     _wanted values expl value compadd -a - compcontext
 
+  elif [[ "${(t)compcontext}" = *assoc* ]]; then
+    local expl tmp i
+
+    tmp=()
+    for i in "${(@k)compcontext[(R)*[^[:blank:]]]}"; do
+      tmp=( "$tmp[@]" "${i}:${compcontext[$i]}" )
+    done
+    tmp=( "$tmp[@]" "${(k@)compcontext[(R)[[:blank:]]#]}" )
+
+    _describe -t values value tmp
+
   elif [[ "$compcontext" = *:*:* ]]; then
     local tag="${${compcontext%%:*}:-values}"
     local descr="${${${compcontext#${tag}:}%%:*}:-value}"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 7687dfb7a..cb0d4880a 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2315,9 +2315,12 @@ named `tt(_tilde)').
 Before trying to find a function for a specific context, tt(_complete) 
 checks if the parameter `tt(compcontext)' is set.  If it is set to an
 array, the elements are taken to be the possible matches which will be
-completed using the tag `tt(values)' and the description `tt(value)'.
-If `tt(compcontext)' to a string containing colons, it should be of
-the form `var(tag)tt(:)var(descr)tt(:)var(action)'. In this case the
+completed using the tag `tt(values)' and the description
+`tt(value)'.   If it is set to an associative array, the keys are used
+as the possible completions and the values (if non-empty) are used as
+descriptions for the matches.  If `tt(compcontext)' is set to a string
+containing colons, it should be of
+the form `var(tag)tt(:)var(descr)tt(:)var(action)'.  In this case the
 var(tag) and var(descr) give the tag and description to use and the
 var(action) says what should be completed in one of the forms
 described for the tt(_arguments) utility function below.