From 6e01a977cc49a19fe6b223b44e12ded7d9ef2061 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 25 Jun 2001 16:10:59 +0000 Subject: Merge a few more dev changes before 4.0.2. --- Completion/Base/Widget/_complete_debug | 24 +++++++++ Completion/Base/Widget/_complete_help | 92 ++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 Completion/Base/Widget/_complete_debug create mode 100644 Completion/Base/Widget/_complete_help (limited to 'Completion') diff --git a/Completion/Base/Widget/_complete_debug b/Completion/Base/Widget/_complete_debug new file mode 100644 index 000000000..1f12e8b9f --- /dev/null +++ b/Completion/Base/Widget/_complete_debug @@ -0,0 +1,24 @@ +#compdef -k complete-word \C-x? + +eval "$_comp_setup" + +(( $+_debug_count )) || integer -g _debug_count +local tmp=${TMPPREFIX}${$}${words[1]:t}$[++_debug_count] +local w="${(qq)words}" + +exec 3>&- # Too bad if somebody else is using it ... +[[ -t 2 ]] && { exec 3>&2 2>| $tmp ; trap 'exec 2>&3 3>&-' EXIT INT } + +setopt xtrace +_main_complete +integer ret=$? +unsetopt xtrace + +[[ -t 3 ]] && { + print -sR "${VISUAL:-${EDITOR:-${PAGER:-more}}} ${(q)tmp} ;: $w" + _message -r "Trace output left in $tmp (up-history to view)" + [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]] && + compstate[list]='list force messages' +} + +return ret diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help new file mode 100644 index 000000000..69930e105 --- /dev/null +++ b/Completion/Base/Widget/_complete_help @@ -0,0 +1,92 @@ +#compdef -k complete-word \C-xh + +_complete_help() { + eval "$_comp_setup" + + 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() { + local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}% *}" + + [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}" + + if [[ "$help_sfuncs[$2]" != *${_f}* || + "$help_styles[${2}${_f}]" != *${3}* ]]; then + [[ "$help_sfuncs[$2]" != *${_f}* ]] && + help_sfuncs[$2]="${help_sfuncs[$2]}:${_f}" + local _t + + case "$1" in + -s) _t='[string] ';; + -a) _t='[array] ';; + -h) _t='[assoc] ';; + *) _t='[boolean]';; + esac + help_styles[${2}${_f}]="${help_styles[${2}${_f}]},${_t} ${3}:${_f}" + 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 + } + trap 'unfunction compadd zstyle' EXIT INT + + _main_complete + + unfunction compadd zstyle + trap - EXIT INT + + for i in "${(@ok)help_funcs}"; do + text="${text} +tags in context :completion:${i}:" + tmp=() + for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do + tmp=( "$tmp[@]" "${(@s.,.)help_tags[${i}${j}][2,-1]}" ) + done + zformat -a tmp ' (' "$tmp[@]" + tmp=( ' + '${^tmp}')' ) + text="${text}${tmp}" + done + + if [[ ${NUMERIC:-1} -ne 1 ]]; then + text="$text +" + for i in "${(@ok)help_sfuncs}"; do + text="${text} +styles in context ${i}" + tmp=() + for j in "${(@s.:.)help_sfuncs[$i][2,-1]}"; do + tmp=( "$tmp[@]" "${(@s.,.)help_styles[${i}${j}][2,-1]}" ) + done + zformat -a tmp ' (' "$tmp[@]" + tmp=( ' + '${^tmp}')' ) + text="${text}${tmp}" + done + fi + compstate[list]='list force' + compstate[insert]='' + + compadd -UX "$text[2,-1]" -n '' +} + +_help_sort_tags() { + local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}% *}" + + if [[ "$help_funcs[$curcontext]" != *${f}* || + "$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then + [[ "$help_funcs[$curcontext]" != *${f}* ]] && + help_funcs[$curcontext]="${help_funcs[$curcontext]}:${f}" + help_tags[${curcontext}${f}]="${help_tags[${curcontext}${f}]},${argv}:${f}" + comptry "$@" + fi +} + +_complete_help "$@" -- cgit 1.4.1