summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2016-06-22 01:37:07 +0200
committerOliver Kiddle <opk@zsh.org>2016-06-22 01:37:07 +0200
commite83489fc4ba168abeb5ea7e23e64383fed181ed3 (patch)
treeb573a21ddbccc2adf8132166b2a7b5a22d6bec6d
parent139a4dbe07728a22dcb120d1ca9ff3cdae98471a (diff)
downloadzsh-e83489fc4ba168abeb5ea7e23e64383fed181ed3.tar.gz
zsh-e83489fc4ba168abeb5ea7e23e64383fed181ed3.tar.xz
zsh-e83489fc4ba168abeb5ea7e23e64383fed181ed3.zip
38714: add x: syntax to match specs to make it possible to disable match specs hardcoded in completion functions
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/compsys.yo5
-rw-r--r--Doc/Zsh/compwid.yo7
-rw-r--r--Src/Zle/complete.c10
4 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c722b79d..d352067e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2016-06-22  Oliver Kiddle  <opk@zsh.org>
 
+	* 38714: Src/Zle/complete.c, Doc/Zsh/compsys.yo,
+	Doc/Zsh/compwid.yo: add x: syntax to match specs to make it
+	possible to disable match specs hardcoded in completion functions
+
 	* 38735: Completion/Unix/Command/_find,
 	Completion/Zsh/Type/_globquals: support verbose style to allow
 	clearer but less compact descriptions for time specifiers
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index c97f80f27..fb0abcef3 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 c01763316..1cc94bf95 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 30fab541a..0c14d86d5 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)