From 7b35c8639c5d36cd06df35f432735b0aa29c08cf Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Tue, 10 Oct 2000 14:12:41 +0000 Subject: *** empty log message *** --- Completion/Builtins/_vars | 16 ++++------------ Completion/Builtins/_zstyle | 5 +++++ Completion/Core/_parameters | 21 ++++++++++++++++++--- Doc/Zsh/compsys.yo | 11 +++++++++++ 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) -- cgit 1.4.1