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

PATCH: was: Re: Inserting all completions



Bart Schaefer wrote:

> [ about the possibility to insert all matches resulting from a
>   completion ]
>
> Maybe all-or-nothing is actually sufficient; what about simply:
> 
> 	compstate[insert]=expand
> 
> Which would act much like the _expand completer with only expand_glob.

This patch adds `all' (not `expand') as a possible value for
`compstate[insert]'. If after the widget has finished it has this
value, all completions are inserted.

The other stuff mentioned in Bart's message will have to wait until we 
have a way to get at the current matches (probably blended with
Peter's suggestion for re-invoking the widget and things like that).

Currently no completion function uses this. Maybe I'll change
`_expand' to allow this kind of `expansion', too.

This also made me notice a uglyness which also happens when using
menu-completion and accept-and-menu-completed in braces. If you have a 
match spec like `m:{a-z}={A-Z}' and to `z{<TAB>' in the Src directory, 
you get `Zle' as one possible match. But if you accept that and then
continue selecting other matches the character before the `{' has the
wrong case for at least one of the matches. Since the `all' value
basically uses the same code, it has the same problem. I have no idea
how to solve this. Any suggestions. (The obvious solution would be to
not use any matches that don't have the same prefix any more, but that 
might be hard to implement. I'll have to think some more about this.)

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Sun Sep 19 16:57:28 1999
+++ Src/Zle/zle_tricky.c	Sun Sep 19 17:32:15 1999
@@ -4735,6 +4735,48 @@
 	    inststr(origline);
 	    cs = origcs;
 	    showinglist = -2;
+	} else if (useline == 2 && nmatches > 1) {
+	    int first = 1, nm = nmatches;
+	    Cmatch *mc;
+
+	    menucmp = 1;
+	    menuacc = 0;
+
+	    for (minfo.group = amatches;
+		 minfo.group && !(minfo.group)->mcount;
+		 minfo.group = (minfo.group)->next);
+
+	    mc = (minfo.group)->matches;
+
+	    while (1) {
+		if (!first)
+		    acceptlast();
+		first = 0;
+
+		if (!--nm)
+		    menucmp = 0;
+
+		do_single(*mc);
+		minfo.cur = mc;
+
+		if (!*++(minfo.cur)) {
+		    do {
+			if (!(minfo.group = (minfo.group)->next))
+			    break;
+		    } while (!(minfo.group)->mcount);
+		    if (!minfo.group)
+			break;
+		    minfo.cur = minfo.group->matches;
+		}
+		mc = minfo.cur;
+	    }
+	    menucmp = 0;
+	    minfo.cur = NULL;
+
+	    if (compforcelist && *compforcelist && uselist)
+		showinglist = -2;
+	    else
+		invalidatelist();
 	} else if (useline) {
 	    /* We have matches. */
 	    if (nmatches > 1) {
@@ -4763,7 +4805,7 @@
 	}
 	/* Print the explanation strings if needed. */
 	if (!showinglist && validlist && usemenu != 2 && nmatches != 1 &&
-	    (!oldlist || !listshown)) {
+	    useline != 2 && (!oldlist || !listshown)) {
 	    Cmgroup g = amatches;
 	    Cexpl *e;
 	    int up = 0, tr = 1, nn = 0;
@@ -5074,6 +5116,8 @@
 	else if (!strcmp(compinsert, "auto") ||
 		 !strcmp(compinsert, "automenu"))
 	    useline = 1, usemenu = 2;
+	else if (!strcmp(compinsert, "all"))
+	    useline = 2, usemenu = 0;
 	else if (idigit(*compinsert)) {
 	    char *m;
 
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo	Sun Sep 19 12:18:54 1999
+++ Doc/Zsh/compwid.yo	Sun Sep 19 17:52:41 1999
@@ -259,6 +259,9 @@
 one more than the maximum selects the first. Unless the value of this
 key ends in a space, the match is inserted as in a menu-completion,
 i.e. without automatically appending a space.
+
+It may also be set to tt(all), which makes all matches generated be
+inserted into the line.
 )
 item(tt(to_end))(
 Specifies the occasions on which the cursor is moved to the end of a string

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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