From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13210 invoked from network); 27 Feb 2001 16:06:52 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Feb 2001 16:06:52 -0000 Received: (qmail 21336 invoked by alias); 27 Feb 2001 16:06:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13544 Received: (qmail 21325 invoked from network); 27 Feb 2001 16:06:44 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Sven Wischnowsky" , Subject: PATCH: RE: incremental matchers in matcher-list Date: Tue, 27 Feb 2001 19:06:39 +0300 Message-ID: <000f01c0a0d7$44686900$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0010_01C0A0F0.69B5A100" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <200102230943.KAA19359@beta.informatik.hu-berlin.de> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C0A0F0.69B5A100 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit > > > > It allows you to add matchers to previous list instead of > replacing them to > > avoid repetitions. > > > > If it accepted, doc and compinstall will follow. > > Would be ok for me (a bit like Bart's zstyle+). > Well, here is a patch with two problems. The matcher-list configuration screen does not fit on standard 80x24 anymore; I do not see any text to remove. And doc addition just mentions the possibility, without explaining much ... Peter, could you look at compinstall? -andrej attached as usual ------=_NextPart_000_0010_01C0A0F0.69B5A100 Content-Type: application/octet-stream; name="matcher-style.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="matcher-style.diff" Index: Completion/Core/_ignored=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Completion/Core/_ignored,v=0A= retrieving revision 1.4=0A= diff -u -r1.4 _ignored=0A= --- Completion/Core/_ignored 2000/06/26 09:36:12 1.4=0A= +++ Completion/Core/_ignored 2001/02/27 16:01:56=0A= @@ -10,7 +10,8 @@=0A= comp=3D( "${(@)_completers[1,_completer_num-1][(R)_ignored(|:*),-1]}" = )=0A= =0A= local _comp_no_ignore=3Dyes tmp expl \=0A= - _completer _completer_num _matcher _matchers _matcher_num=0A= + _completer _completer_num \=0A= + _matcher _c_matcher _matchers _matcher_num=0A= =0A= _completer_num=3D1=0A= =0A= @@ -30,7 +31,13 @@=0A= _matchers=3D( '' )=0A= =0A= _matcher_num=3D1=0A= - for _matcher in "$_matchers[@]"; do=0A= + _matcher=3D''=0A= + for _c_matcher in "$_matchers[@]"; do=0A= + if [[ "$_c_matcher" =3D=3D +* ]]; then=0A= + _matcher=3D"$_matcher $_c_matcher[2,-1]"=0A= + else=0A= + _matcher=3D"$_c_matcher"=0A= + fi=0A= if [[ "$tmp" !=3D _ignored ]] && "$tmp"; then=0A= if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&=0A= [[ $compstate[old_list] !=3D shown &&=0A= Index: Completion/Core/_main_complete=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v=0A= retrieving revision 1.43=0A= diff -u -r1.43 _main_complete=0A= --- Completion/Core/_main_complete 2000/10/19 08:58:17 1.43=0A= +++ Completion/Core/_main_complete 2001/02/27 16:01:56=0A= @@ -25,8 +25,8 @@=0A= =0A= local func funcs ret=3D1 tmp _compskip format nm call match min max i = num\=0A= _completers _completer _completer_num curtag _comp_force_list \=0A= - _matchers _matcher _matcher_num _comp_tags _comp_mesg mesg str \=0A= - context state line opt_args val_args curcontext=3D"$curcontext" \=0A= + _matchers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg = \=0A= + mesg str context state line opt_args val_args = curcontext=3D"$curcontext" \=0A= _last_nmatches=3D-1 _last_menu_style _def_menu_style _menu_style = sel \=0A= _saved_exact=3D"${compstate[exact]}" \=0A= _saved_lastprompt=3D"${compstate[last_prompt]}" \=0A= @@ -143,7 +143,14 @@=0A= _matchers=3D( '' )=0A= =0A= _matcher_num=3D1=0A= - for _matcher in "$_matchers[@]"; do=0A= + _matcher=3D''=0A= + for _c_matcher in "$_matchers[@]"; do=0A= + if [[ "$_c_matcher" =3D=3D +* ]]; then=0A= + _matcher=3D"$_matcher $_c_matcher[2,-1]"=0A= + else=0A= + _matcher=3D"$_c_matcher"=0A= + fi=0A= +=0A= _comp_mesg=3D=0A= if [[ -n "$call" ]]; then=0A= if "${(@)argv[3,-1]}"; then=0A= Index: Completion/Core/_prefix=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Completion/Core/_prefix,v=0A= retrieving revision 1.3=0A= diff -u -r1.3 _prefix=0A= --- Completion/Core/_prefix 2000/05/08 08:16:32 1.3=0A= +++ Completion/Core/_prefix 2001/02/27 16:01:56=0A= @@ -5,7 +5,8 @@=0A= [[ _matcher_num -gt 1 || -z "$SUFFIX" ]] && return 1=0A= =0A= local comp curcontext=3D"$curcontext" tmp \=0A= - _completer _completer_num _matcher _matchers _matcher_num=0A= + _completer _completer_num \=0A= + _matcher _c_matcher _matchers _matcher_num=0A= =0A= zstyle -a ":completion:${curcontext}:" completer comp ||=0A= comp=3D( "${(@)_completers[1,_completer_num-1][(R)_prefix(|:*),-1]}" )=0A= @@ -35,7 +36,14 @@=0A= _matchers=3D( '' )=0A= =0A= _matcher_num=3D1=0A= - for _matcher in "$_matchers[@]"; do=0A= + _matcher=3D''=0A= + for _c_matcher in "$_matchers[@]"; do=0A= + if [[ "$_c_matcher" =3D=3D +* ]]; then=0A= + _matcher=3D"$_matcher $_c_matcher[2,-1]"=0A= + else=0A= + _matcher=3D"$_c_matcher"=0A= + fi=0A= +=0A= [[ "$tmp" !=3D _prefix ]] && "$tmp" && return 0=0A= (( _matcher_num++ ))=0A= done=0A= Index: Completion/Core/compinstall=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Completion/Core/compinstall,v=0A= retrieving revision 1.18=0A= diff -u -r1.18 compinstall=0A= --- Completion/Core/compinstall 2000/07/12 11:04:07 1.18=0A= +++ Completion/Core/compinstall 2001/02/27 16:01:57=0A= @@ -856,6 +856,10 @@=0A= else=0A= # toggle off=0A= eval "${1}[$2]=3D' '"=0A= + if [[ $c_list[$2] =3D=3D ' ' && $C_list[$2] =3D=3D ' ' && \=0A= + $p_list[$2] =3D=3D ' ' && $s_list[$2] =3D=3D ' ' ]]; then=0A= + a_or_r[$2]=3D' '=0A= + fi=0A= return 1=0A= fi=0A= }=0A= @@ -867,7 +871,7 @@=0A= # More specific use of matchers is usually covered by completion = functions.=0A= =0A= local mlist m_ci m_pw m_sub c_list C_list p_list s_list pw_seps key = key2 elt=0A= - local pw_dstar=0A= + local pw_dstar a_or_r i=0A= integer eltcnt lastnz=0A= =0A= __ci_get_this_style matcher-list mlist=0A= @@ -876,13 +880,14 @@=0A= eval "mlist=3D($mlist)"=0A= # ?_list say whether the four possible matchers are set for passes 1,=0A= # 2, 3, 4, in an easy-to-read manner, i.e. the Nth part of the string=0A= - # is either N (on) or space (off).=0A= + # is one of N (on) or space (off).=0A= + a_or_r=3D" " # replace by default=0A= n_list=3D" " # null completion, i.e. standard=0A= c_list=3D" " # case match one way=0A= C_list=3D" " # case match both ways=0A= p_list=3D" " # partial word completion=0A= s_list=3D" " # substring completion=0A= - # $pws_seps gives the separators used for partial-word completion=0A= + # $pw_seps gives the separators used for partial-word completion=0A= # by element of the matcher list; these can be edited separately.=0A= pw_seps=3D('._-' '._-' '._-' '._-')=0A= pw_dstar=3D('' '' '' '')=0A= @@ -890,6 +895,7 @@=0A= # See what's in the matcher initially. If these have been edited,=0A= # we're in trouble, but that's pretty much true of everything.=0A= for (( eltcnt =3D 1; eltcnt <=3D $#mlist; eltcnt++ )); do=0A= + [[ $mlist[eltcnt] =3D=3D "+"* ]] && a_or_r[$eltcnt]=3D'+'=0A= [[ -z $mlist[$eltcnt] ]] && n_list[$eltcnt]=3D$eltcnt=0A= [[ $mlist[$eltcnt] =3D *"m:{a-z}=3D{A-Z}"* ]] && = c_list[$eltcnt]=3D$eltcnt=0A= [[ $mlist[$eltcnt] =3D *"m:{a-zA-Z}=3D{A-Za-z}"* ]] && = C_list[$eltcnt]=3D$eltcnt=0A= @@ -912,14 +918,16 @@=0A= =0A= \`Matchers' allow the completion code to play extra tricks when = comparing=0A= the string on the command line with a possible match, as listed below.=0A= -A list of different matchers can be given; each is tried until at least=0A= -one possible completion is found. The numbers given below show what is=0A= -included in each element of the list; everything for 1 is tried at the = same=0A= -time, and if necessary everything for 2, etc. If no matcher is set=0A= -ordinary completion will be done at that point. Elements from 1 to 4 = can=0A= -be set; empty trailing elements will be removed, and if nothing is set, = the=0A= -style will not be set.=0A= +A list of different matchers can be given. The numbers given below show = what is=0A= +included in each element of the list; by default everything for 1 is = tried=0A= +at the same time, then if necessary everything for 2, etc. until at = least=0A= +one possible completion is found. You can change it so that every = element=0A= +in the list is added to preceding one(s) instead; this indicated by '+' = over=0A= +the element. If no matcher is set ordinary completion will be done at = that=0A= +point. Elements from 1 to 4 can be set; empty trailing elements will be=0A= +removed, and if nothing is set, the style will not be set.=0A= =0A= + ($a_or_r)=0A= n. ($n_list)\=0A= No matchers; you may want to try this as the first choice.=0A= c. ($c_list)\=0A= @@ -933,6 +941,7 @@=0A= Substring completion: complete on substrings, not just initial=0A= strings. Warning: it is recommended this not be used for = element 1.=0A= =0A= +t. Toggle replace/augment for matcher group=0A= q. Return without saving.=0A= 0. Done setting matchers.=0A= "=0A= @@ -981,6 +990,18 @@=0A= read -q key && pw_dstar[$key2]=3D'*'=0A= fi=0A= ;;=0A= + [tT])=0A= + read -k key2'?Toggle augment/replace for elements number (1234)? '=0A= + if [[ $key2 =3D=3D [1234] ]]; then=0A= + if [[ $a_or_r[$key2] =3D=3D ' ' ]]; then=0A= + a_or_r[$key2]=3D'+'=0A= + else=0A= + a_or_r[$key2]=3D' '=0A= + fi=0A= + else=0A= + print "Only 1, 2, 3 and 4 are handled."=0A= + fi=0A= + ;;=0A= [sS]) __ci_toggle_matcher s_list $key2=0A= ;;=0A= [qQ]) return 1=0A= @@ -1010,6 +1031,7 @@=0A= elt=3D"${elt:+$elt }l:|=3D* r:|=3D*"=0A= fi=0A= fi=0A= + [[ $a_or_r[$eltcnt] !=3D ' ' ]] && elt=3D"+$elt"=0A= [[ -n $elt || $n_list[$eltcnt] !=3D ' ' ]] && lastnz=3D$eltcnt=0A= mlist[$eltcnt]=3D$elt=0A= done=0A= Index: Doc/Zsh/compsys.yo=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v=0A= retrieving revision 1.105=0A= diff -u -r1.105 compsys.yo=0A= --- Doc/Zsh/compsys.yo 2001/01/15 09:11:33 1.105=0A= +++ Doc/Zsh/compsys.yo 2001/02/27 16:01:59=0A= @@ -1538,6 +1538,13 @@=0A= =0A= example(zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}=3D{A-Za-z}')=0A= =0A= +By default every specification replaces previous ones. If specification=0A= +is prefixed with tt(+), it is added to the existing list. This allows=0A= +testing more general patterns without repeating the whole list every=0A= +time, as in:=0A= +=0A= +example(zstyle ':completion:*' matcher-list '' '+m{a-Z}=3D{A-Z}' = '+m{A-Z}=3D{a-z}')=0A= +=0A= The style allows even finer control by specifying a particular = completer,=0A= without the leading underscore, in the third field of the completion=0A= context. For example, if one uses the completers tt(_complete) and=0A= ------=_NextPart_000_0010_01C0A0F0.69B5A100--