2001-04-02 13:14:40 +02:00
|
|
|
#compdef -k complete-word \C-xh
|
|
|
|
|
|
|
|
_complete_help() {
|
2001-05-29 13:59:50 +02:00
|
|
|
eval "$_comp_setup"
|
2001-04-02 13:14:40 +02:00
|
|
|
|
|
|
|
local _sort_tags=_help_sort_tags text i j k tmp
|
|
|
|
typeset -A help_funcs help_tags help_sfuncs help_styles
|
|
|
|
|
|
|
|
compadd() { return 1 }
|
|
|
|
zstyle() {
|
2002-07-08 10:59:38 +02:00
|
|
|
local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}"
|
2001-04-02 13:14:40 +02:00
|
|
|
|
2002-07-08 10:59:38 +02:00
|
|
|
[[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}"
|
2001-04-02 13:14:40 +02:00
|
|
|
|
|
|
|
if [[ "$help_sfuncs[$2]" != *${_f}* ||
|
|
|
|
"$help_styles[${2}${_f}]" != *${3}* ]]; then
|
2002-01-03 19:26:56 +01:00
|
|
|
|
|
|
|
[[ "$help_sfuncs[$2]" != *${_f}* ]] && help_sfuncs[$2]+=$'\0'"${_f}"
|
2001-04-02 13:14:40 +02:00
|
|
|
local _t
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-s) _t='[string] ';;
|
|
|
|
-a) _t='[array] ';;
|
|
|
|
-h) _t='[assoc] ';;
|
|
|
|
*) _t='[boolean]';;
|
|
|
|
esac
|
2002-01-03 19:26:56 +01:00
|
|
|
help_styles[${2}${_f}]+=",${_t} ${3}:${_f}"
|
2001-04-02 13:14:40 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# No need to call the completers more than once with different match specs.
|
|
|
|
|
|
|
|
if [[ "$3" = matcher-list ]]; then
|
|
|
|
set -A "$4" ''
|
|
|
|
else
|
|
|
|
builtin zstyle "$@"
|
|
|
|
fi
|
|
|
|
}
|
2001-06-21 12:05:19 +02:00
|
|
|
trap 'unfunction compadd zstyle' EXIT INT
|
2001-04-02 13:14:40 +02:00
|
|
|
|
|
|
|
_main_complete
|
|
|
|
|
|
|
|
unfunction compadd zstyle
|
2001-06-21 12:05:19 +02:00
|
|
|
trap - EXIT INT
|
2001-04-02 13:14:40 +02:00
|
|
|
|
|
|
|
for i in "${(@ok)help_funcs}"; do
|
2002-01-03 19:26:56 +01:00
|
|
|
text+=$'\n'"tags in context :completion:${i}:"
|
2001-04-02 13:14:40 +02:00
|
|
|
tmp=()
|
2002-01-03 19:26:56 +01:00
|
|
|
for j in "${(@ps.\0.)help_funcs[$i][2,-1]}"; do
|
|
|
|
tmp+=( "${(@s.,.)help_tags[${i}${j}][2,-1]}" )
|
2001-04-02 13:14:40 +02:00
|
|
|
done
|
|
|
|
zformat -a tmp ' (' "$tmp[@]"
|
2002-01-03 19:26:56 +01:00
|
|
|
tmp=( $'\n '${^tmp}')' )
|
|
|
|
text+="${tmp}"
|
2001-04-02 13:14:40 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ${NUMERIC:-1} -ne 1 ]]; then
|
2002-01-03 19:26:56 +01:00
|
|
|
text+=$'\n'
|
2001-04-02 13:14:40 +02:00
|
|
|
for i in "${(@ok)help_sfuncs}"; do
|
2002-01-03 19:26:56 +01:00
|
|
|
text+=$'\n'"styles in context ${i}"
|
2001-04-02 13:14:40 +02:00
|
|
|
tmp=()
|
2002-01-03 19:26:56 +01:00
|
|
|
for j in "${(@ps.\0.)help_sfuncs[$i][2,-1]}"; do
|
|
|
|
tmp+=( "${(@s.,.)help_styles[${i}${j}][2,-1]}" )
|
2001-04-02 13:14:40 +02:00
|
|
|
done
|
|
|
|
zformat -a tmp ' (' "$tmp[@]"
|
2002-01-03 19:26:56 +01:00
|
|
|
tmp=( $'\n '${^tmp}')' )
|
|
|
|
text+="${tmp}"
|
2001-04-02 13:14:40 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
compstate[list]='list force'
|
|
|
|
compstate[insert]=''
|
|
|
|
|
|
|
|
compadd -UX "$text[2,-1]" -n ''
|
|
|
|
}
|
|
|
|
|
|
|
|
_help_sort_tags() {
|
2002-07-08 10:59:38 +02:00
|
|
|
local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}"
|
2001-04-02 13:14:40 +02:00
|
|
|
|
|
|
|
if [[ "$help_funcs[$curcontext]" != *${f}* ||
|
|
|
|
"$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then
|
|
|
|
[[ "$help_funcs[$curcontext]" != *${f}* ]] &&
|
2002-01-03 19:26:56 +01:00
|
|
|
help_funcs[$curcontext]+=$'\0'"${f}"
|
|
|
|
help_tags[${curcontext}${f}]+=",${argv}:${f}"
|
2001-04-02 13:14:40 +02:00
|
|
|
comptry "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_complete_help "$@"
|