From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22981 invoked from network); 5 Feb 2002 16:25:49 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 5 Feb 2002 16:25:49 -0000 Received: (qmail 27046 invoked by alias); 5 Feb 2002 16:25:43 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16565 Received: (qmail 27032 invoked from network); 5 Feb 2002 16:25:40 -0000 From: Sven Wischnowsky MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15456.1849.401288.393433@wischnow.berkom.de> Date: Tue, 5 Feb 2002 17:24:25 +0100 To: zsh-workers@sunsite.dk Subject: Re: new fake style, completion grouping etc In-Reply-To: <20020205161317.65408.qmail@web9304.mail.yahoo.com> References: <15454.19703.823266.240649@wischnow.berkom.de> <20020205161317.65408.qmail@web9304.mail.yahoo.com> X-Mailer: VM 6.95 under 21.5 (patch 3) "asparagus" XEmacs Lucid Oliver Kiddle wrote: > --- Sven Wischnowsky wrote: > > > But in the case of _arguments, the tag is created created > > automatically, so the user couldn't know it (well, he could know it > > beacuse we know how they are constructed, but...). > > > > Maybe we should make _guard derive the name from the -[JV] argument, > > that would be saver than it sounds (the group name is set from the > > group-name style, which is tag for most people using it at all, and > > it > > would ensure that the matches are really in the same group). > > I'm not sure that I like the idea of using the group name - seems a bit > hacky. I'd be more inclined to make _arguments call _guard for some > special action syntax, e.g. :-/pattern/. That's why I didn't do it yet. Although I have a patch here with that change and some others. But... > > I've thought about this, too, several times, but didn't dare it yet. > > Maybe we should just do it and make 4.1 the phase of completion code > > cleanup. > > > > This wouldn't really help in this case, though. Because _describe > > adds > > the matches with -V to be able to get the right layout. If one of the > > real matches gets added earlier, the list display will get messed up. > > Well, it would help in that all the matches would be together in the > same list under the same description. The fake matches would just not > be sorted so the layout might not be ideal. since I'm far from sure (actually, I doubt) we'll ever be able to cleanly fix this, we should probably re-think this. The problem isn't just that the layout might be `not ideal', it may become completely messed up or without duplicates removed. We could circumvent all these problems by just admitting it and make faked matches be added under a different tag, i.e. in a different group. With a default description of `faked matches' or a user supplied one. Would that be inacceptable? Anyway, below is that patch (including a possible fix for the _arguments-x thing we were discussing). Not to be committed right now. Bye Sven diff -ur -r ../oz/Completion/Base/Core/_all_labels ./Completion/Base/Core/_all_labels --- ../oz/Completion/Base/Core/_all_labels Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_all_labels Mon Feb 4 22:20:29 2002 @@ -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 @@ _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 -ur -r ../oz/Completion/Base/Core/_description ./Completion/Base/Core/_description --- ../oz/Completion/Base/Core/_description Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_description Mon Feb 4 22:20:33 2002 @@ -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 @@ 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 @@ -80,6 +80,8 @@ local descr descr=( "${(@M)match:#*[^\\]:*}" ) + + _fake_contexts=( "$_fake_contexts[@]" ":completion:${curcontext}:$tag" ) compadd "${(@P)name}" - "${(@)${(@)match:#*[^\\]:*}:s/\\:/:/}" (( $#descr )) && _describe -t "$tag" '' descr "${(@P)name}" diff -ur -r ../oz/Completion/Base/Core/_main_complete ./Completion/Base/Core/_main_complete --- ../oz/Completion/Base/Core/_main_complete Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_main_complete Mon Feb 4 20:04:20 2002 @@ -22,6 +22,7 @@ _completers _completer _completer_num curtag _comp_force_list \ _matchers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg \ mesg str context state line opt_args val_args curcontext="$curcontext" \ + _fake_contexts \ _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \ _saved_exact="${compstate[exact]}" \ _saved_lastprompt="${compstate[last_prompt]}" \ @@ -75,6 +76,7 @@ ) _last_menu_style=() +_fake_contexts=() if zstyle -s ":completion:${curcontext}:default" list-prompt tmp; then LISTPROMPT="$tmp" diff -ur -r ../oz/Completion/Base/Core/_message ./Completion/Base/Core/_message --- ../oz/Completion/Base/Core/_message Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_message Mon Feb 4 20:13:03 2002 @@ -1,6 +1,6 @@ #autoload -local format raw +local format raw grp if [[ "$1" = -e ]]; then local expl ret=1 @@ -12,9 +12,22 @@ ret=0 done + (( $_fake_contexts[(I):completion:${curcontext}:$2] )) || + compstate[insert]= + return ret fi +if [[ $1 = -[JV]?* ]]; then + grp=( "$1" ) + shift +elif [[ $1 = -[JV]* ]]; then + grp=( "$1" "$2" ) + shift 2 +else + grp=() +fi + _tags messages || return 1 if [[ "$1" = -r ]]; then @@ -28,6 +41,6 @@ if [[ -n "$format$raw" ]]; then [[ -z "$raw" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}" - builtin compadd -x "$format" + builtin compadd "$grp[@]" -x "$format" _comp_mesg=yes fi diff -ur -r ../oz/Completion/Base/Core/_next_label ./Completion/Base/Core/_next_label --- ../oz/Completion/Base/Core/_next_label Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_next_label Mon Feb 4 22:20:19 2002 @@ -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 -ur -r ../oz/Completion/Base/Core/_requested ./Completion/Base/Core/_requested --- ../oz/Completion/Base/Core/_requested Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_requested Mon Feb 4 22:20:14 2002 @@ -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 -ur -r ../oz/Completion/Base/Core/_wanted ./Completion/Base/Core/_wanted --- ../oz/Completion/Base/Core/_wanted Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Core/_wanted Mon Feb 4 22:20:51 2002 @@ -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 -ur -r ../oz/Completion/Base/Utility/_guard ./Completion/Base/Utility/_guard --- ../oz/Completion/Base/Utility/_guard Tue Jan 29 20:40:18 2002 +++ ./Completion/Base/Utility/_guard Mon Feb 4 19:40:11 2002 @@ -1,17 +1,18 @@ #autoload -local mesg pat garbage +local mesg grp pat garbage mesg=() -zparseopts -K -D -a garbage M: J: V: 1 2 n F: X:=mesg +grp=() +zparseopts -K -D -a garbage M: J:=grp V:=grp 1 2 n F: X:=mesg [[ "$PREFIX$SUFFIX" != $~1 ]] && return 1 if [[ $# -gt 1 || $#mesg -eq 0 ]]; then shift - _message "$*" + _message "$grp[@]" "$*" else - _message -r "$mesg[2]" + _message "$grp[@]" -r "$mesg[2]" fi [[ -n "$PREFIX$SUFFIX" ]] diff -ur -r ../oz/Doc/Zsh/compsys.yo ./Doc/Zsh/compsys.yo --- ../oz/Doc/Zsh/compsys.yo Tue Jan 29 20:40:18 2002 +++ ./Doc/Zsh/compsys.yo Mon Feb 4 21:19:58 2002 @@ -3692,7 +3692,7 @@ followed by another character, only options are completed. ) findex(_message) -xitem(tt(_message) [ tt(-r) ] var(descr)) +xitem(tt(_message) [ tt(-[JV]) var(group) ] [ tt(-r) ] 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 @@ -3708,6 +3708,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. + +If the tt(-V) or tt(-J) option is given, the var(descr) will be added +to the named var(group). 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 diff -ur -r ../oz/Src/Zle/compcore.c ./Src/Zle/compcore.c --- ../oz/Src/Zle/compcore.c Tue Jan 29 20:40:18 2002 +++ ./Src/Zle/compcore.c Mon Feb 4 20:00:08 2002 @@ -1619,6 +1619,17 @@ Heap oldheap; SWITCHHEAPS(oldheap, compheap) { + /* Select the group in which to store the matches. */ + gflags = (((dat->aflags & CAF_NOSORT ) ? CGF_NOSORT : 0) | + ((dat->aflags & CAF_UNIQALL) ? CGF_UNIQALL : 0) | + ((dat->aflags & CAF_UNIQCON) ? CGF_UNIQCON : 0)); + if (dat->group) { + endcmgroup(NULL); + begcmgroup(dat->group, gflags); + } else { + endcmgroup(NULL); + begcmgroup("default", 0); + } if (dat->mesg || dat->exp) { curexpl = (Cexpl) zhalloc(sizeof(struct cexpl)); curexpl->always = !!dat->mesg; @@ -1630,23 +1641,9 @@ curexpl = NULL; } SWITCHBACKHEAPS(oldheap); - if (!*argv && !dat->dummies && !(dat->aflags & CAF_ALL)) { - SWITCHHEAPS(oldheap, compheap) { - /* Select the group in which to store the matches. */ - gflags = (((dat->aflags & CAF_NOSORT ) ? CGF_NOSORT : 0) | - ((dat->aflags & CAF_UNIQALL) ? CGF_UNIQALL : 0) | - ((dat->aflags & CAF_UNIQCON) ? CGF_UNIQCON : 0)); - if (dat->group) { - endcmgroup(NULL); - begcmgroup(dat->group, gflags); - } else { - endcmgroup(NULL); - begcmgroup("default", 0); - } - } SWITCHBACKHEAPS(oldheap); - + if (!*argv && !dat->dummies && !(dat->aflags & CAF_ALL)) return 1; - } + if (dat->dummies) dat->aflags = (dat->aflags | CAF_NOSORT | CAF_UNIQCON) & ~CAF_UNIQALL; for (bp = brbeg; bp; bp = bp->next) @@ -1880,17 +1877,6 @@ haspattern = 1; } } - } - /* Select the group in which to store the matches. */ - gflags = (((dat->aflags & CAF_NOSORT ) ? CGF_NOSORT : 0) | - ((dat->aflags & CAF_UNIQALL) ? CGF_UNIQALL : 0) | - ((dat->aflags & CAF_UNIQCON) ? CGF_UNIQCON : 0)); - if (dat->group) { - endcmgroup(NULL); - begcmgroup(dat->group, gflags); - } else { - endcmgroup(NULL); - begcmgroup("default", 0); } if (*argv) { if (dat->pre) diff -ur -r ../oz/Test/Y03arguments.ztst ./Test/Y03arguments.ztst --- ../oz/Test/Y03arguments.ztst Mon Feb 4 20:18:05 2002 +++ ./Test/Y03arguments.ztst Mon Feb 4 20:19:02 2002 @@ -91,7 +91,7 @@ comptest $'tst -\t' 0:argument beginning with minus >line: {tst -}{} ->MESSAGE:{arg} +>DESCRIPTION:{arg} >DESCRIPTION:{option} >NO:{-x} -- Sven Wischnowsky wischnow@informatik.hu-berlin.de