Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: extended compctl bug in 3.1.5



Greg Klanderman wrote:

> Hi,
> 
> I hope this example will illustrate two bugs in using the "R" pattern
> in extended completion:
> 
> compctl -k '(foo bar)' -x 'R[bar,foo]' -k '(a b c)' \
>              - 'R[foo,;]' -k '(1 2 3)' -- foobar
> 
> First, type "foobar foo", with no space after "foo" and hit TAB.  You
> get a beep and no completions, because the 'R[foo,;]' clause is
> matching even though you are not after but ON the word with prefix
> 'foo'.  I would expect it to complete "foo" by appending the suffix
> space.

Yes, we should probably avoid this.

> Second, type "foobar foo bar ", with a space after "bar".  Hit TAB and
> you get the completions "a", "b", and "c", which you should not, as
> you are not before "foo".

This, however is intentional -- think about cases where you want to
have multiple groups of `foo ... bar'. But the manual could be
clearer...

I don't know if you can apply this patch to an unmodified 3.1.5.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Tue Jun 22 11:51:29 1999
+++ Src/Zle/zle_tricky.c	Tue Jun 22 15:24:27 1999
@@ -5631,7 +5631,7 @@
 		    case CCT_RANGEPAT:
 			if (cc->type == CCT_RANGEPAT)
 			    tokenize(sc = dupstring(cc->u.l.a[i]));
-			for (j = clwpos; j; j--) {
+			for (j = clwpos - 1; j > 0; j--) {
 			    untokenize(s = ztrdup(clwords[j]));
 			    if (cc->type == CCT_RANGESTR)
 				sc = rembslash(cc->u.l.a[i]);
diff -u od/Zsh/compctl.yo Doc/Zsh/compctl.yo
--- od/Zsh/compctl.yo	Tue Jun 22 11:51:38 1999
+++ Doc/Zsh/compctl.yo	Tue Jun 22 15:26:22 1999
@@ -633,7 +633,8 @@
 )
 item(tt(r[)var(str1)tt(,)var(str2)tt(])...)(
 Matches if the cursor is after a word with prefix var(str1).  If there
-is also a word with prefix var(str2) on the command line it matches
+is also a word with prefix var(str2) on the command line after the one 
+matched by var(str1) it matches
 only if the cursor is before this word. If the comma and var(str2) are
 omitted, it matches if the cursor is after a word with prefix var(str1).
 )

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author