From 77339cc21d723eed88e6e621d831ba28c6110b6d Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Tue, 12 Feb 2002 13:37:00 +0000 Subject: add -x option (to be passed on to compadd) to _description and friends; make _message respect any -[12VJ] options it gets, adding the message to that group (16609) --- ChangeLog | 10 ++++++++++ Completion/Base/Core/_all_labels | 12 +++++------- Completion/Base/Core/_description | 18 +++++++++--------- Completion/Base/Core/_message | 7 +++++-- Completion/Base/Core/_next_label | 12 +++++------- Completion/Base/Core/_requested | 12 +++++------- Completion/Base/Core/_wanted | 21 +++++---------------- Doc/Zsh/compsys.yo | 25 ++++++++++++++++--------- 8 files changed, 60 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3be457011..02f6ff37b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-02-12 Sven Wischnowsky + + * 16609: Completion/Base/Core/_all_labels, + Completion/Base/Core/_description, Completion/Base/Core/_message, + Completion/Base/Core/_next_label, + Completion/Base/Core/_requested, Completion/Base/Core/_wanted, + Doc/Zsh/compsys.yo: add -x option (to be passed on to compadd) + to _description and friends; make _message respect any -[12VJ] + options it gets, adding the message to that group + 2002-02-09 Clint Adams * unposted: Functions/Prompts/prompt_clint_setup: diff --git a/Completion/Base/Core/_all_labels b/Completion/Base/Core/_all_labels index 8665f5bf3..9dda58131 100644 --- a/Completion/Base/Core/_all_labels +++ b/Completion/Base/Core/_all_labels @@ -1,16 +1,14 @@ #autoload -local __gopt=-J __len __tmp __pre __suf __ret=1 __descr __spec __prev +local __gopt __len __tmp __pre __suf __ret=1 __descr __spec __prev if [[ "$1" = - ]]; then __prev=- shift fi -if [[ "$1" = -([12]|)[VJ] ]]; then - __gopt="$1" - shift -fi +__gopt=() +zparseopts -D -a __gopt 1 2 V J x __tmp=${argv[(ib:4:)-]} __len=$# @@ -29,12 +27,12 @@ while comptags "-A$__prev" "$1" curtag __spec; do _comp_tags="$_comp_tags $__spec " if [[ "$curtag" = *[^\\]:* ]]; then zformat -f __descr "${curtag#*:}" "d:$3" - _description "$__gopt" "${curtag%:*}" "$2" "$__descr" + _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr" curtag="${curtag%:*}" "$4" "${(P@)2}" "${(@)argv[5,-1]}" && __ret=0 else - _description "$__gopt" "$curtag" "$2" "$3" + _description "$__gopt[@]" "$curtag" "$2" "$3" "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0 fi diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description index 30e6dfa9b..41f4f2483 100644 --- a/Completion/Base/Core/_description +++ b/Completion/Base/Core/_description @@ -1,13 +1,13 @@ #autoload -local name gropt=-J format gname hidden hide match opts tag +local name gropt nopt xopt format gname hidden hide match opts tag opts=() -if [[ "$1" = -([12]|)[VJ] ]]; then - gropt="$1" - shift -fi +gropt=(-J) +xopt=(-X) +nopt=() +zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt 3="${${3##[[:blank:]]#}%%[[:blank:]]#}" [[ -n "$3" ]] && _lastdescr=( "$_lastdescr[@]" "$3" ) @@ -62,15 +62,15 @@ fi if [[ -n "$gname" ]]; then if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$gropt" "$gname" -X "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" "$xopt" "$format" else - set -A "$name" "$opts[@]" "$gropt" "$gname" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" fi else if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$gropt" -default- -X "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- "$xopt" "$format" else - set -A "$name" "$opts[@]" "$gropt" -default- + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- fi fi diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message index 44512f648..979dfa097 100644 --- a/Completion/Base/Core/_message +++ b/Completion/Base/Core/_message @@ -1,6 +1,6 @@ #autoload -local format raw +local format raw gopt if [[ "$1" = -e ]]; then local expl ret=1 @@ -15,6 +15,9 @@ if [[ "$1" = -e ]]; then return ret fi +gopt=() +zparseopts -D -a gopt 1 2 V J + _tags messages || return 1 if [[ "$1" = -r ]]; then @@ -28,6 +31,6 @@ fi if [[ -n "$format$raw" ]]; then [[ -z "$raw" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}" - builtin compadd -x "$format" + builtin compadd "$gopt[@]" -x "$format" _comp_mesg=yes fi diff --git a/Completion/Base/Core/_next_label b/Completion/Base/Core/_next_label index 48845229a..ff9b658a1 100644 --- a/Completion/Base/Core/_next_label +++ b/Completion/Base/Core/_next_label @@ -1,21 +1,19 @@ #autoload -local __gopt=-J __descr __spec +local __gopt __descr __spec -if [[ "$1" = -([12]|)[VJ] ]]; then - __gopt="$1" - shift -fi +__gopt=() +zparseopts -D -a __gopt 1 2 V J x if comptags -A "$1" curtag __spec; then _comp_tags="$_comp_tags $__spec " if [[ "$curtag" = *[^\\]:* ]]; then zformat -f __descr "${curtag#*:}" "d:$3" - _description "$__gopt" "${curtag%:*}" "$2" "$__descr" + _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr" curtag="${curtag%:*}" set -A $2 "${(P@)2}" "${(@)argv[4,-1]}" else - _description "$__gopt" "$curtag" "$2" "$3" + _description "$__gopt[@]" "$curtag" "$2" "$3" set -A $2 "${(@)argv[4,-1]}" "${(P@)2}" fi diff --git a/Completion/Base/Core/_requested b/Completion/Base/Core/_requested index 5614098bc..4ba52ce7f 100644 --- a/Completion/Base/Core/_requested +++ b/Completion/Base/Core/_requested @@ -1,17 +1,15 @@ #autoload -local __gopt=-J +local __gopt -if [[ "$1" = -([12]|)[VJ] ]]; then - __gopt="$1" - shift -fi +__gopt=() +zparseopts -D -a __gopt 1 2 V J x if comptags -R "$1"; then if [[ $# -gt 3 ]]; then - _all_labels - "$__gopt" "$@" || return 1 + _all_labels - "$__gopt[@]" "$@" || return 1 elif [[ $# -gt 1 ]]; then - _description "$__gopt" "$@" + _description "$__gopt[@]" "$@" fi return 0 else diff --git a/Completion/Base/Core/_wanted b/Completion/Base/Core/_wanted index 3e25fdbbc..f96b266bd 100644 --- a/Completion/Base/Core/_wanted +++ b/Completion/Base/Core/_wanted @@ -1,26 +1,15 @@ #autoload -local __targs __gopt=-J +local __targs __gopt -if [[ "$1" = -C?* ]]; then - __targs=( -C "${1[3,-1]}" ) - shift -elif [[ "$1" = -C ]]; then - __targs=( -C "$2" ) - shift 2 -else - __targs=() -fi - -if [[ "$1" = -([12]|)[VJ] ]]; then - __gopt="$1" - shift -fi +__gopt=() +__tagrs=() +zparseopts -D -a __gopt 1 2 V J x C:=__targs _tags "$__targs[@]" "$1" while _tags; do - _all_labels "$__gopt" "$@" && return 0 + _all_labels "$__gopt[@]" "$@" && return 0 done return 1 diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 683dbb493..b899e19f9 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -2930,7 +2930,7 @@ put themselves into the arrays again. startitem() findex(_all_labels) -item(tt(_all_labels) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])( +item(tt(_all_labels) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])( This is a convenient interface to the tt(_next_label) function below, implementing the loop shown in the tt(_next_label) example. The var(command) is the one that should be called to generate the matches. The @@ -3587,7 +3587,7 @@ tt(_describe) uses the tt(_all_labels) function to generate the matches, so it does not need to appear inside a loop over tag labels. ) findex(_description) -item(tt(_description) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])( +item(tt(_description) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])( This function is called before completions are added (typically by a call to tt(compadd)); it tests various styles and arranges for any necessary options to be passed on to tt(compadd). The styles are tested in the @@ -3609,7 +3609,10 @@ not contain an explanation string to be displayed above the matches. If tt(_description) is called with more than three arguments, the additional var(specs) should be of the form `var(char)tt(:)var(str)' and every appearance of `tt(%)var(char)' in the format string will be -replaced by var(string). +replaced by var(string). If the tt(-x) option is given, the +description will be added using the tt(-x) option instead of the +default tt(-X), i.e. the description will even be displayed if no +matches are added for the description. The options placed in the array will also make sure that the matches are placed in a separate group, depending on the value of the @@ -3692,7 +3695,7 @@ tt(_guard)), only the message will be displayed and if the `tt(-n)' is followed by another character, only options are completed. ) findex(_message) -xitem(tt(_message) [ tt(-r) ] var(descr)) +xitem(tt(_message) [ tt(-r12) ] [ tt(-VJ) var(group) ] var(descr)) item(tt(_message -e) var(tag descr))( The var(descr) is used like the third argument to the tt(_description) function. However, the resulting @@ -3709,6 +3712,9 @@ used literally as the string to display. This is only used in cases where that string is taken from some pre-processed argument list containing an expanded description. +The tt(-12VJ) options and the var(group) are passed to tt(compadd) and +hence determine the group the message string is added to. + In the second form, the var(descr) is added like a description added by tt(_description) under the given var(tag), but the var(descr) will always be shown even if no matches are added for the var(tag). @@ -3741,13 +3747,13 @@ Like other utility functions, this function accepts the `tt(-V)', them to the tt(compadd) builtin. ) findex(_next_label) -item(tt(_next_label) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])( +item(tt(_next_label) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])( This function should be called repeatedly to generate the tag labels. On each call it will check if another tag label is to be used and, if there is at least one, zero is returned. If no more tag labels are to be used, a non-zero status is returned. -The tt(-12JV) options and the first three arguments are given to the +The tt(-x12VJ) options and the first three arguments are given to the tt(_description) function using the tag label instead of the first argument as appropriate. The var(options) given after the var(descr) should be other options to be used for tt(compadd) or whatever @@ -3932,7 +3938,7 @@ Either of the two var(spec)s can be matched. enditem() ) findex(_requested) -item(tt(_requested) [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])( +item(tt(_requested) [ tt(-x) ] [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])( This function is called to decide whether a tag already registered by a call to tt(_tags) (see below) is requested and hence completion should be performed for it; it returns status zero if the tag is requested and @@ -4159,7 +4165,7 @@ which case you have to make the parameter tt(curcontext) local instead of tt(context) (as described above). ) findex(_wanted) -item(tt(_wanted) [ tt(-C) var(name) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) var(command) var(args) ...)( +item(tt(_wanted) [ tt(-x) ] [ tt(-C) var(name) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) var(command) var(args) ...)( In many contexts, completion will generate one particular set of matches (usually corresponding to a single tag); however, it is still necessary to decide whether the user requires matches of this type. @@ -4183,7 +4189,8 @@ Note that, as for tt(_requested), the var(command) has to accept the options that have to be passed down to tt(compadd). Like tt(_tags) this function supports the tt(-C) option to give a -different name for the argument context field. +different name for the argument context field. The tt(-x) option has +the same meaning as for tt(_description). ) enditem() -- cgit 1.4.1