1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 22:51:42 +02:00

if compcontext is an assoc, the keys are the completions and the values are their descriptions (12483)

This commit is contained in:
Sven Wischnowsky 2000-08-02 10:36:19 +00:00
parent eabfc368bd
commit b2aebcad02
4 changed files with 23 additions and 5 deletions

View file

@ -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

View file

@ -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[@]" )

View file

@ -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}"

View file

@ -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.