summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-26 08:16:39 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-26 08:16:39 +0000
commitf90992ec3170a70a65d11ed9fd2aa4c6baaec3eb (patch)
treefab9f0f2f2b607e90c35bcf3f294f5bfd7f8448b /Completion/Base
parentb758c1072641d20671e3416391b8683c9e0c81aa (diff)
downloadzsh-f90992ec3170a70a65d11ed9fd2aa4c6baaec3eb.tar.gz
zsh-f90992ec3170a70a65d11ed9fd2aa4c6baaec3eb.tar.xz
zsh-f90992ec3170a70a65d11ed9fd2aa4c6baaec3eb.zip
allow _value:<assoc> functions to override completion for all keys of an assoc (3337)
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_value8
1 files changed, 7 insertions, 1 deletions
diff --git a/Completion/Base/_value b/Completion/Base/_value
index 402bab236..15218eb60 100644
--- a/Completion/Base/_value
+++ b/Completion/Base/_value
@@ -2,10 +2,16 @@
 
 _value () {
   # You can customize completion for different parameters by writing a
-  # function `_value:<name>'.
+  # function `_value:<name>', where <name> is the name of the parameter.
+  # When completing values of elements of associative arrays, we first
+  # search for a function `_value:<assoc>-<key>' and then for 
+  # `_value:<assoc>', so it's simple to define different functions
+  # for different keys or one function for a whole association.
 
   if (( $+functions[_value:$compstate[parameter]] )); then
     "_value:$compstate[parameter]" "$@"
+  elif (( $+functions[_value:${compstate[parameter]%%-*}] )); then
+    "_value:${compstate[parameter]%%-*}" "$@"
   elif [[ "$compstate[parameter]" != *-* &&
           "${(Pt)${compstate[parameter]}}" = assoc* ]]; then
     if (( CURRENT & 1 )); then