Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1466284627; bh=mZkoDlr6ZUJZhnCd36RYSLA3DIsrzoF0NRbUB6PHyr4=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=hirn6zu2nBOkTRC7QgdtHdnHG+OzlA0qHCU+7YQQE7/py6dzDJVfD45dODavpoo2YJvr9z52hQEbpJIYOTIvQ7JgPB7446xpdkrqws+s0EOC9ilnDpOP+t4gvuqVcRv9byn5kInqontOLK8bJrgDHJaolu7blwMrBC25FnYSWVX8zr746GaUPh6TquHzlxwiAW3OAdxDyTs5UswIKjW17zPSvXn0U/4H6zcWStpY30KOUKEAfhP4G4PsSfHWHwTn/I5kM0fLkYs/AH+MhRrsCQnb5wi2ZxUuQzW1BCtvcIdi30FXa/aneLUU0I/1pHt3Zm1lqD6683k4NcrpLl8orw==
X-Yahoo-Newman-Id: 141867.35429.bm@smtp132.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: Nd1nxb8VM1nlrkU0TA10_Hncf85PZ3eaJGqVHZmaOVniaTi
 oK_v5RObV.L6IEHA3466ce.YtoLe5hpTXIka4DsRNgBGzPTEQPnn7d4JS8dG
 zfxpKvVmipQHDiMSFU16JdG7JWIRJrMK4_LlRw_2eLl3.lHOt58CB4GtwZ0Q
 gZjuoBuhx3O_qGZfjjbp0B.fkQv8R.NdIrf9xQeVh9smCFm_KZbiMkuN.qgZ
 c4e6HPsSqqD_6tX.4tqYvJypkmIIoz.A_LURKhpAgocWVpeYvK1bh.j9srYe
 .xCv8iVFFoEDdM1BTi1A_bSK6l.HHejx0tioK1RQiorFed.gcAIYbH0i_4xE
 sFGqCcPvhm5_55e14TqmGaw.vPo6FjuYzAah8vOL1jgsVMHNfzWJ5Nl1r3Nh
 yO8E_eG4wgSxjI.GWZwf.oXLExUzJfV_A9q6LDVKFd62JEV_WgKhX0mcFy2O
 XGsmEt2JYeULDP92NZOU.eMk9CKGyvvPcjMQ0ChM1LL8WXR2La1_EfjmuqDU
 gnpBF9iuJ0hNu2A92wpSeAizfIZWr_w--
X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI-
In-reply-to: <fc6b9fc8-e37f-1756-ed08-c87d5ffd7317@gmx.com>
From: Oliver Kiddle <okiddle@yahoo.co.uk>
References: <57504DEC.9000101@redhat.com> <2aa4c678-6d5e-0614-7aff-e374c3108ba3@gmx.com> <5312.1465896712@thecus.kiddle.eu> <fc6b9fc8-e37f-1756-ed08-c87d5ffd7317@gmx.com>
To: zsh-workers@zsh.org
Subject: PATCH: allow default match specs to be disabled (was Re: [PATCH v4] zsh localedef completion)
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <23450.1466284625.1@thecus.kiddle.eu>
Date: Sat, 18 Jun 2016 23:17:05 +0200
Message-ID: <23451.1466284625@thecus.kiddle.eu>
X-Seq: zsh-workers 38714

On 15 Jun, Eric Cook wrote:
>
> > Perhaps we could
> > allow a special token in match specs that would cause subsequent specs
> > to be ignored or filtered?
>
> If it isn't hard to do, sure; i wouldn't mind it.

Turns out it isn't hard to do.

This patch uses x: as the token. Any thoughts on that or alternative
suggestions?

There's nothing in the documentation to suggest that the ordering of
matching specifications has any effect. Is anyone aware of whether it
perhaps does?

The documentation of the matcher style was perhaps deceptive in
indicating that it is tried before matcher-list. The value is merely
placed before those from matcher-list.

Oliver

diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index c97f80f..fb0abce 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2023,8 +2023,9 @@ only be performed with the `tt(*)' inserted.
 kindex(matcher, completion style)
 item(tt(matcher))(
 This style is tested separately for each tag valid in the current
-context.  Its value is tried before any match specifications given by the 
-tt(matcher-list) style.  It should be in the form described in
+context.  Its value is placed before any match specifications given by the
+tt(matcher-list) style so can override them via the use of an tt(x:)
+specification.  The value should be in the form described in
 ifzman(the section `Completion Matching Control' in zmanref(zshcompwid))\
 ifnzman(noderef(Completion Matching Control))\
 .  For examples of this, see the description of the tt(tag-order) style.
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index c017633..1cc94bf 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -913,6 +913,13 @@ line and trial completion patterns are anchored on the right side.
 Here an empty var(ranchor) and the tt(e) and tt(E) forms force the
 match to the end of the command line or trial completion string.
 )
+item(tt(x:))(
+This form is used to mark the end of matching specifications:
+subsequent specifications are ignored. In a single standalone list
+of specifications this has no use but where matching specifications
+are accumulated, such as from nested function calls, it can allow one
+function to override another.
+)
 enditem()
 
 Each var(lpat), var(tpat) or var(anchor) is either an empty string or
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 30fab54..0c14d86 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -241,6 +241,7 @@ parse_cmatcher(char *name, char *s)
 	case 'E': fl2 = CMF_INTER;
 	case 'R': fl = CMF_RIGHT | CMF_LINE; break;
 	case 'M': fl = CMF_LINE; break;
+	case 'x': break;
 	default:
 	    if (name)
 		zwarnnam(name, "unknown match specification character `%c'",
@@ -252,6 +253,15 @@ parse_cmatcher(char *name, char *s)
 		zwarnnam(name, "missing `:'");
 	    return pcm_err;
 	}
+	if (*s == 'x') {
+	    if (s[2] && !inblank(s[2])) {
+		if (name)
+		    zwarnnam(name,
+			"unexpected pattern following x: specification");
+		return pcm_err;
+	    }
+	    return ret;
+	}
 	s += 2;
 	if (!*s) {
 	    if (name)

