mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
if compcontext is an assoc, the keys are the completions and the values are their descriptions (12483)
This commit is contained in:
parent
eabfc368bd
commit
b2aebcad02
4 changed files with 23 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
2000-08-02 Sven Wischnowsky <wischnow@zsh.org>
|
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
|
* 12475: Completion/Base/_arguments: prefer user-defined specs
|
||||||
over ones derived from --help output
|
over ones derived from --help output
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ if (( long )); then
|
||||||
|
|
||||||
# Using (( ... )) gives a parse error.
|
# Using (( ... )) gives a parse error.
|
||||||
|
|
||||||
let "$tmpargv[(I)(|\([^\)]#\))${opt}(|[-+=])(|\[*\])(|:*)]" ||
|
let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+=])(|\[*\])(|:*)]" ||
|
||||||
tmp=( "$tmp[@]" "$opt" )
|
tmp=( "$tmp[@]" "$opt" )
|
||||||
done
|
done
|
||||||
lopts=( "$tmp[@]" )
|
lopts=( "$tmp[@]" )
|
||||||
|
|
|
@ -13,11 +13,22 @@ oldcontext="$curcontext"
|
||||||
|
|
||||||
if [[ -n "$compcontext" ]]; then
|
if [[ -n "$compcontext" ]]; then
|
||||||
|
|
||||||
if [[ "${(t)compcontext}" = *(array|assoc)* ]]; then
|
if [[ "${(t)compcontext}" = *array* ]]; then
|
||||||
local expl
|
local expl
|
||||||
|
|
||||||
_wanted values expl value compadd -a - compcontext
|
_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
|
elif [[ "$compcontext" = *:*:* ]]; then
|
||||||
local tag="${${compcontext%%:*}:-values}"
|
local tag="${${compcontext%%:*}:-values}"
|
||||||
local descr="${${${compcontext#${tag}:}%%:*}:-value}"
|
local descr="${${${compcontext#${tag}:}%%:*}:-value}"
|
||||||
|
|
|
@ -2315,9 +2315,12 @@ named `tt(_tilde)').
|
||||||
Before trying to find a function for a specific context, tt(_complete)
|
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
|
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
|
array, the elements are taken to be the possible matches which will be
|
||||||
completed using the tag `tt(values)' and the description `tt(value)'.
|
completed using the tag `tt(values)' and the description
|
||||||
If `tt(compcontext)' to a string containing colons, it should be of
|
`tt(value)'. If it is set to an associative array, the keys are used
|
||||||
the form `var(tag)tt(:)var(descr)tt(:)var(action)'. In this case the
|
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(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
|
var(action) says what should be completed in one of the forms
|
||||||
described for the tt(_arguments) utility function below.
|
described for the tt(_arguments) utility function below.
|
||||||
|
|
Loading…
Reference in a new issue