1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-31 18:10:56 +01:00
zsh/Completion/Base/_describe
1999-12-10 14:47:55 +00:00

50 lines
1.1 KiB
Text

#autoload
# This can be used to add options or values with descriptions as matches.
local _opt _expl _tmps _tmpd _tmpmd _tmpms _ret=1 _showd _nm _hide _args
local _type=values
# Get the option.
if [[ "$1" = -o ]]; then
_type=options
shift
fi
# Do the tests. `showd' is set if the descriptions should be shown.
_tags "$_type" || return 1
zstyle -t ":completion${curcontext}:$_type" verbose && _showd=yes
_description "$_type" _expl "$1"
shift
if [[ -n "$_showd" ]]; then
compdescribe -I ' -- ' "$@"
else
compdescribe -i "$@"
fi
[[ "$_type" = options ]] &&
zstyle -t ":completion${curcontext}:options" prefix-hidden && _hide=yes
while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do
# See if we should remove the option prefix characters.
if [[ -n "$_hide" ]]; then
if [[ "$PREFIX" = --* ]]; then
_tmpd=( "${(@)_tmpd#--}" )
_tmps=( "${(@)_tmps#--}" )
elif [[ "$PREFIX" = [-+]* ]]; then
_tmpd=( "${(@)_tmpd#[-+]}" )
_tmps=( "${(@)_tmps#[-+]}" )
fi
fi
compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0
compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0
done
return _ret