summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Base/Utility/_pick_variant8
-rw-r--r--Doc/Zsh/compsys.yo8
-rw-r--r--Src/Zle/zle_tricky.c41
4 files changed, 62 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a9b214167..bc4572ad4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-14 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 29820: Doc/Zsh/compsys.yo,
+ Completion/Base/Utility/_pick_variant: -b option to match
+ builtins.
+
2011-10-12 Mikael Magnusson <mikachu@gmail.com>
* 29815: Doc/Makefile.in: include mod_langinfo in documentation.
@@ -15455,5 +15461,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5475 $
+* $Revision: 1.5476 $
*****************************************************
diff --git a/Completion/Base/Utility/_pick_variant b/Completion/Base/Utility/_pick_variant
index 01fa2b98f..9099e3599 100644
--- a/Completion/Base/Utility/_pick_variant
+++ b/Completion/Base/Utility/_pick_variant
@@ -6,7 +6,7 @@ local -A opts
(( $+_cmd_variant )) || typeset -gA _cmd_variant
-zparseopts -D -A opts c: r:
+zparseopts -D -A opts b: c: r:
: ${opts[-c]:=$words[1]}
while [[ $1 = *=* ]]; do
@@ -19,6 +19,12 @@ if (( $+_cmd_variant[$opts[-c]] )); then
return 0
fi
+if [[ $+opts[-b] -eq 1 && -n $builtins[$opts[-c]] ]]; then
+ _cmd_variant[$opts[-c]]=$opts[-b]
+ (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}"
+ return 0
+fi
+
output="$(_call_program variant $opts[-c] "${@[2,-1]}" </dev/null 2>&1)"
for cmd pat in "$var[@]"; do
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index d3d272c10..e07ac0e9e 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -4387,7 +4387,9 @@ tt(ambiguous), tt(special-dirs), tt(list-suffixes) and tt(file-sort)
described above.
)
findex(_pick_variant)
-item(tt(_pick_variant [ tt(-c) var(command) ] [ tt(-r) var(name) ] var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ]))(
+xitem(tt(_pick_variant) [ tt(-b) var(builtin-label) ] [ tt(-c)
+var(command) ] [ tt(-r) var(name) ])
+item( var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ])(
This function is used to resolve situations where a single command name
requires more than one type of handling, either because it
has more than one variant or because there is a name clash between two
@@ -4403,6 +4405,10 @@ tt(...)' contains var(pattern), then tt(label) is selected as the label
for the command variant. If none of the patterns match, the final
command label is selected and status 1 is returned.
+If the `tt(-b) var(builtin-label)' is given, the command is tested to
+see if it is provided as a shell builtin, possibly autoloaded; if so,
+the label var(builtin-label) is selected as the label for the variant.
+
If the `tt(-r) var(name)' is given, the var(label) picked is stored in
the parameter named var(name).
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 999b2b7be..6fa887a1e 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1869,6 +1869,10 @@ get_comp_string(void)
}
} else if (p < curs) {
if (*p == Outbrace) {
+ /*
+ * HERE: strip and remember code from last
+ * comma to here.
+ */
cant = 1;
break;
}
@@ -1876,6 +1880,16 @@ get_comp_string(void)
char *tp = p;
if (!skipparens(Inbrace, Outbrace, &tp)) {
+ /*
+ * Balanced brace: skip.
+ * We only deal with unfinished braces, so
+ * something{foo<x>bar,morestuff}else
+ * doesn't work
+ *
+ * HERE: instead, continue, look for a comma.
+ * Stack tp and brace for popping when we
+ * find a comma at each level.
+ */
i += tp - p - 1;
dp += tp - p - 1;
p = tp - 1;
@@ -1918,10 +1932,16 @@ get_comp_string(void)
hascom = 1;
}
} else {
+ /* On or after the cursor position */
if (*p == Inbrace) {
char *tp = p;
if (!skipparens(Inbrace, Outbrace, &tp)) {
+ /*
+ * Balanced braces after the cursor.
+ * Could do the same with these as
+ * those before the cursor.
+ */
i += tp - p - 1;
dp += tp - p - 1;
p = tp - 1;
@@ -1932,6 +1952,14 @@ get_comp_string(void)
break;
}
if (p == curs) {
+ /*
+ * We've reached the cursor position.
+ * If there's a pending open brace at this
+ * point we need to stack the text.
+ * We've marked the bit we don't want from
+ * bbeg to bend, which might be a comma
+ * between the opening brace and us.
+ */
if (bbeg) {
Brinfo new;
int len = bend - bbeg;
@@ -1961,10 +1989,23 @@ get_comp_string(void)
bbeg = NULL;
}
if (*p == Comma) {
+ /*
+ * Comma on or after cursor.
+ * We set bbeg to NULL at the cursor; here
+ * it's being used to find the first comma
+ * afterwards.
+ */
if (!bbeg)
bbeg = p;
hascom = 2;
} else if (*p == Outbrace) {
+ /*
+ * Closing brace on or after the cursor.
+ * Not sure how this can be after the cursor;
+ * if it was matched, wouldn't we have skipped
+ * over the group, and if it wasn't, surely we're
+ * not interested in it?
+ */
Brinfo new;
int len;