From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id a379ff7b for ; Mon, 9 Mar 2020 11:33:18 +0000 (UTC) Received: (qmail 21933 invoked by alias); 9 Mar 2020 11:33:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45523 Received: (qmail 29757 invoked by uid 1010); 9 Mar 2020 11:33:09 -0000 X-Qmail-Scanner-Diagnostics: from forward105p.mail.yandex.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25744. spamassassin: 3.4.2. Clear:RC:0(77.88.28.108):SA:0(-2.0/5.0):. Processed in 1.578043 secs); 09 Mar 2020 11:33:09 -0000 X-Envelope-From: oxiedi@yandex.ru X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf-ipv4.yandex.ru designates 77.88.28.108 as permitted sender) Authentication-Results: mxback26o.mail.yandex.net; dkim=pass header.i=@yandex.ru From: oxiedi@yandex.ru Envelope-From: oxiedi@yandex.ru To: zsh-workers@zsh.org Subject: [PATCH] Merge ignore and deduplication patterns in _sequence MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Mon, 09 Mar 2020 16:32:30 +0500 Message-Id: <3932941583753550@myt2-a7d7570d35ff.qloud-c.yandex.net> Content-Transfer-Encoding: 7bit Content-Type: text/plain First, it fixes the following bug: % zsh -f % autoload -Uz compinit % compinit -D % compdef '_arguments ": :_sequence compadd - 1 2 3"' seq % zstyle ':completion:*:*:seq:*:*' ignored-patterns 2 % seq _sequence:40: command not found: -F Second, it allows a user to ignore matches using the ignored-patterns style. diff --git a/Completion/Base/Utility/_sequence b/Completion/Base/Utility/_sequence index c1ff32184..cb79960f2 100644 --- a/Completion/Base/Utility/_sequence +++ b/Completion/Base/Utility/_sequence @@ -8,10 +8,11 @@ # -d : duplicate values allowed local curcontext="$curcontext" nm="$compstate[nmatches]" pre qsep nosep minus -local -a opts sep num pref suf cont end uniq dedup +local ign_pats +local -a opts sep num pref suf cont end ign uniq dedup zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf \ - q=suf r:=suf R:=suf C:=cont d=uniq M+: J+: V+: 1 2 o+: X+: x+: + q=suf r:=suf R:=suf C:=cont F:=ign d=uniq M+: J+: V+: 1 2 o+: X+: x+: (( $#cont )) && curcontext="${curcontext%:*}:$cont[2]" (( $#sep )) || sep[2]=, @@ -20,12 +21,22 @@ if (( $+suf[(r)-S] )); then (( $#end )) && compset -S ${end}\* && suf=() && nosep=1 fi +ign_pats=$ign[2] +if [[ $ign_pats == \(*\) ]]; then + ign=( ${=ign_pats[2,-2]} ) +elif [[ -n $ign_pats ]]; then + ign=( ${(P)ign_pats} ) +else + ign=() +fi + qsep="${sep[2]}" compquote -p qsep if (( ! $#uniq )); then (( $+pref[(r)-P] )) && pre="${(q)pref[pref[(i)-P]+1]}" dedup=( "${(@)${(@ps.$qsep.)PREFIX#$pre}[1,-2]}" "${(@)${(@ps.$qsep.)SUFFIX}[2,-1]}" ) [[ -n $compstate[quoting] ]] || dedup=( ${(Q)dedup} ) + ign+=( "$dedup[@]" ) fi if (( $#num )) && compset -P $(( num[2] - 1 )) \*${(q)qsep}; then @@ -37,4 +48,4 @@ else fi (( minus = argv[(ib:2:)-] )) -"${(@)argv[1,minus-1]}" "$opts[@]" -F dedup "$pref[@]" "$suf[@]" "${(@)argv[minus+1,-1]}" +"${(@)argv[1,minus-1]}" "$opts[@]" -F ign "$pref[@]" "$suf[@]" "${(@)argv[minus+1,-1]}" diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index 51f604bcf..c616e606e 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -216,6 +216,57 @@ F:regression test workers/31611 >NO:{3pm} >NO:{10pm} + comptesteval "_tst() { _arguments ':desc:_sequence -d compadd - 1 2 3' }" + comptesteval "zstyle ':completion:*:tst:*' ignored-patterns 2" + comptest $'tst 1,\t' +0:ignore matches in _sequence via the ignored-patterns style (without deduplication) +>line: {tst 1,}{} +>DESCRIPTION:{desc} +>NO:{1} +>NO:{3} + + comptesteval "_tst() { _arguments ':desc:_sequence compadd - 1 2 3 4' }" + comptest $'tst 1,\t' + comptesteval "zstyle -d ':completion:*:tst:*' ignored-patterns" +0:ignore matches in _sequence via the ignored-patterns style (with deduplication) +>line: {tst 1,}{} +>DESCRIPTION:{desc} +>NO:{3} +>NO:{4} + comptest $'a=() b=(\t' 0:multiple envarrays >line: {a=() b=(}{}