summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Completion/Builtins/_vars16
-rw-r--r--Completion/Builtins/_zstyle5
-rw-r--r--Completion/Core/_parameters21
-rw-r--r--Doc/Zsh/compsys.yo11
4 files changed, 38 insertions, 15 deletions
diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars
index 501e37b4f..dece0fecb 100644
--- a/Completion/Builtins/_vars
+++ b/Completion/Builtins/_vars
@@ -6,20 +6,12 @@
 local ret=1
 
 if [[ $PREFIX = *\[* ]]; then
-  local var=${PREFIX%%\[*}
-  local elt="${PREFIX#*\]}${SUFFIX%\]}"
-  local addclose
+  compstate[parameter]=${PREFIX%%(|\\)\[*}
 
-  compset -p $(( ${#var} + 1 ))
-  if ! compset -S \]; then
-    addclose=(-S "${${QIPREFIX:+]}:-\]}")
-  fi
-  if [[ ${(tP)var} = assoc* ]]; then
-    local expl
+  IPREFIX=${PREFIX%%\[*}\[
+  PREFIX=${PREFIX#*\[}
 
-    _wanted -C subscript association-keys expl 'association key' \
-        compadd $addclose -k "$var"
-  fi
+  _subscript -q
 else
   _parameters -g '^a*' "$@" && ret=0
   
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 3a485f0da..62e5369e4 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -25,6 +25,7 @@ styles=(
   domains                c:
   expand		 c:
   fake			 c:fake
+  fake-parameters	 c:fake-params
   file-patterns		 c:filepat
   file-sort              c:fsort
   force-list             c:
@@ -269,6 +270,10 @@ while [[ -n $state ]]; do
       _message 'prefix and names'
       ;;
 
+    fake-params)
+      _message 'name and optional type'
+      ;;
+
     ignline) 
       _wanted values expl boolean compadd true false current current-shown other
       ;;
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index b49d60dda..097a96760 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -6,10 +6,25 @@
 # If you specify a -g option with a pattern, the pattern will be used to
 # restrict the type of parameters matched.
 
-local expl pattern
+local expl pattern fakes faked tmp
 
 pattern=(-g \*)
 zparseopts -D -K -E g:=pattern
 
-_wanted parameters expl parameter compadd "$@" \
-   -Q -k "parameters[(R)${pattern[2]}~*local*]"
+fakes=()
+faked=()
+if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then
+  for i in "$tmp[@]"; do
+    if [[ "$i" = *:* ]]; then
+      faked=( "$faked[@]" "$i" )
+    else
+      fakes=( "$fakes[@]" "$i" )
+    fi
+  done
+fi
+
+_wanted parameters expl parameter \
+    compadd "$@" -Q - \
+        "${(@k)parameters[(R)${pattern[2]}~*local*]}" \
+        "$fakes[@]" \
+        "${(@)${(@M)faked:#${~pattern[2]}}%%:*}"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 92d85e259..11837cb49 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1020,6 +1020,17 @@ such files really exist.
 This can be useful on systems that support special filesystems whose
 top-level pathnames can not be listed or generated with glob patterns.
 )
+kindex(fake-parameters, completion style)
+item(tt(fake-parameters))(
+This is used by the completion function generating parameter names as
+matches.  Its values are names of parameters which might not yet be
+set, but which should be completed nonetheless.  Each name may also be 
+followed by a colon and a string specifying the type of the parameter
+(like `tt(scalar)', `tt(array)' or `tt(integer)').  If such a type is
+given, the name will only be completed if parameters of that type are
+requested in the particular context.  Names for which no type is
+specified will always be completed.
+)
 kindex(file-patterns, completion style)
 item(tt(file-patterns))(
 In most places where filenames are completed, the function tt(_files)