From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27412 invoked from network); 28 Mar 2000 09:06:31 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Mar 2000 09:06:31 -0000 Received: (qmail 1875 invoked by alias); 28 Mar 2000 09:06:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10293 Received: (qmail 1865 invoked from network); 28 Mar 2000 09:06:23 -0000 Date: Tue, 28 Mar 2000 11:05:43 +0200 (MET DST) Message-Id: <200003280905.LAA09964@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: _complete_help This updates _complete_help for the changed tag stuff and makes the display a bit nicer (alignment of the function information). Then it makes it display styles as far as it can. I.e. the information shown (which is already quite a bit if one uses many completers) may be incomplete (I already said this when the question first came up, and I'm still not happy with showing such a incomplete list, but maybe some people find it useful anyway). This is mostly intended as a test how useful this might be. If people like it, we should probably make _complete_help test a style to find out if the list of styles should be shown or not (i.e. one can switch it on or off, depending on the default we decide to use). The good thing about the style list is that it made me notice two small bugs, one in _default (it used ':completion:${curcontext}...' with single quotes) and one in _main_complete ($curcontext wasn't reset after the loop). Bye Sven diff -ru ../z.old/Completion/Base/_default Completion/Base/_default --- ../z.old/Completion/Base/_default Tue Mar 28 10:08:34 2000 +++ Completion/Base/_default Tue Mar 28 10:37:25 2000 @@ -2,7 +2,7 @@ local ctl -if { zstyle -s ':completion:${curcontext}:' use-compctl ctl || +if { zstyle -s ":completion:${curcontext}:" use-compctl ctl || zmodload -e zsh/compctl } && [[ "$ctl" != (no|false|0|off) ]]; then local opt diff -ru ../z.old/Completion/Commands/_complete_help Completion/Commands/_complete_help --- ../z.old/Completion/Commands/_complete_help Tue Mar 28 10:08:40 2000 +++ Completion/Commands/_complete_help Tue Mar 28 10:47:02 2000 @@ -1,21 +1,62 @@ #compdef -k complete-word \C-xh _complete_help() { - local _sort_tags=_help_sort_tags text i j - typeset -A help_funcs help_tags + local _sort_tags=_help_sort_tags text i j k + 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|loop|try)}% *}" + + [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}" + + 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 + builtin zstyle "$@" + } _main_complete - unfunction compadd + unfunction compadd zstyle - for i in "${(@k)help_funcs}"; do + 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 - text="${text}${help_tags[${i}${j}]} (${j})" + tmp=( "$tmp[@]" "${(@s.,.)help_tags[${i}${j}][2,-1]}" ) done + zformat -a tmp ' (' "$tmp[@]" + tmp=( ' + '${^tmp}')' ) + text="${text}${tmp}" + done + + 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 compstate[list]='list force' @@ -25,11 +66,13 @@ } _help_sort_tags() { - local f="${${${funcstack[3,(i)_(main_complete|complete|approximate|normal)]}% *}#_(wanted|requested) }" - if [[ "$help_funcs[$curcontext]" != *${f}* ]]; then - help_funcs[$curcontext]="${help_funcs[$curcontext]}:${f}" - help_tags[${curcontext}${f}]="${help_tags[$curcontext]} - ${argv}" + local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}% *}" + + 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 } diff -ru ../z.old/Completion/Core/_main_complete Completion/Core/_main_complete --- ../z.old/Completion/Core/_main_complete Tue Mar 28 10:08:42 2000 +++ Completion/Core/_main_complete Tue Mar 28 10:39:50 2000 @@ -58,12 +58,15 @@ # Get the names of the completers to use in the positional parameters. -(( $# )) || zstyle -a ":completion:${curcontext}:" completer argv || - set _complete +if (( $# )); then + _completers=( "$@" ) +else + zstyle -a ":completion:${curcontext}:" completer _completers || + _completers=( _complete ) +fi # And now just call the completer functions defined. -_completers=( "$@" ) _completer_num=1 # Call the pre-functions. @@ -74,7 +77,7 @@ "$func" done -for tmp; do +for tmp in "$_completers[@]"; do if [[ "$tmp" = *:-* ]]; then _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}" @@ -100,6 +103,8 @@ done (( _completer_num++ )) done + +curcontext="${curcontext/:[^:]#:/::}" if [[ $compstate[old_list] = keep || $compstate[nmatches] -gt 1 ]]; then [[ _last_nmatches -ge 0 && _last_nmatches -ne $compstate[nmatches] ]] && diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo --- ../z.old/Doc/Zsh/compsys.yo Mon Mar 27 16:34:42 2000 +++ Doc/Zsh/compsys.yo Tue Mar 28 10:58:45 2000 @@ -353,9 +353,10 @@ The tt(_complete_help) bindable command described in ifzman(the section `Bindable Commands' below)\ ifnzman(noderef(Bindable Commands)) -can be invoked to find out the context and tag names used at a particular +can be invoked to find out the context and tag names and styles used at a particular point in completion. It shows a list of context names and the -tag names used in those contexts if completion were tried at the +tag names used in those contexts and then a list of context names and +the styles used in those contexts if completion were tried at the current cursor position. Hence one can easily find out all the information needed to change the behaviour of the tt(tag-order) style for a particular context. @@ -2169,9 +2190,15 @@ ) findex(_complete_help (^Xh)) item(tt(_complete_help (^Xh)))( -This widget displays information about the context names, including -the tags, and the completion functions used +This widget displays information about the context names, +the tags, the styles, and the completion functions used when completing at the current cursor position. + +Note that, depending on the control flow in the completion functions +called, the information about the styles may be +incomplete. I.e. depending on the settings for some styles other +styles may be used, and, depending on the user's settings, only the +first sort of styles may be detected by tt(_complete_help). ) enditem() -- Sven Wischnowsky wischnow@informatik.hu-berlin.de