zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: complist
@ 1999-07-07  8:23 Sven Wischnowsky
  1999-07-09  7:47 ` accept-and-infer-next-history in path completion Andrej Borsenkow
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 1999-07-07  8:23 UTC (permalink / raw)
  To: zsh-workers


Yes, I was in a really weird mood yesterday...

This makes accept-and-infer-next-history be treated specially when in
menu-selection. It accepts the current match and immediatly starts
completion again. So if you have a list of files, place the mark on a
directory and execute a-a-i-n-h, you can select files in that
directory. Of course it would be nice to be able to go back again,
e.g. with undo, but implementing that is a bit more complicated...

Bye
 Sven

diff -u -r kos/Zle/complist.c Src/Zle/complist.c
--- kos/Zle/complist.c	Wed Jul  7 09:13:22 1999
+++ Src/Zle/complist.c	Wed Jul  7 09:13:48 1999
@@ -645,6 +645,7 @@
 static int
 domenuselect(Hookdef dummy, Chdata dat)
 {
+    static Chdata fdat = NULL;
     Cmatch **p;
     Cmgroup *pg;
     Thingy cmd;
@@ -652,10 +653,15 @@
     int i = 0, acc = 0;
     char *s;
 
-    if (dummy && (!(s = getsparam("SELECTMIN")) ||
-		  (dat && dat->num < atoi(s))))
+    if (fdat || (dummy && (!(s = getsparam("SELECTMIN")) ||
+			   (dat && dat->num < atoi(s))))) {
+	if (fdat) {
+	    fdat->matches = dat->matches;
+	    fdat->num = dat->num;
+	}
 	return 0;
-
+    }
+    fdat = dat;
     selectlocalmap(mskeymap);
     noselect = 0;
     mselect = (*(minfo.cur))->gnum;
@@ -686,6 +692,18 @@
 	else if (cmd == Th(z_acceptline)) {
 	    acc = 1;
 	    break;
+	} else if (cmd == Th(z_acceptandinfernexthistory)) {
+	    menucmp = 0;
+	    menucomplete(zlenoargs);
+	    if (dat->num < 2 || !minfo.cur || !*(minfo.cur)) {
+		noselect = 1;
+		break;
+	    }
+	    clearlist = 1;
+	    zrefresh();
+	    clearlist = 0;
+	    mselect = (*(minfo.cur))->gnum;
+	    continue;
 	} else if (cmd == Th(z_acceptandhold) ||
 		 cmd == Th(z_acceptandmenucomplete)) {
 	    Menustack s = (Menustack) zhalloc(sizeof(*s));
@@ -858,6 +876,7 @@
 	showinglist = -2;
 	zrefresh();
     }
+    fdat = NULL;
     return (!noselect ^ acc);
 }
 
diff -u -r kos/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- kos/Zle/zle_tricky.c	Wed Jul  7 09:13:23 1999
+++ Src/Zle/zle_tricky.c	Wed Jul  7 09:13:48 1999
@@ -4372,6 +4372,7 @@
 	    cs = origcs;
 	    clearlist = 1;
 	    ret = 1;
+	    minfo.cur = NULL;
 	    goto compend;
 	}
 	if (comppatmatch && *comppatmatch && comppatmatch != opm)
diff -u kod/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
--- kod/Zsh/mod_complist.yo	Wed Jul  7 09:13:29 1999
+++ Doc/Zsh/mod_complist.yo	Wed Jul  7 10:22:35 1999
@@ -100,12 +100,16 @@
 functions. The zle functions tt(send-break) and tt(accept-line) can be used
 to leave menu-selection, leaving the match currently inserted into the line
 in place. In the case of tt(accept-line), the match currently inserted
-will be accepted and the immediatly trying completion again will
+will be accepted and immediatly trying completion again will
 complete after it. Using tt(send-break) leaves menu-selection and
 continues with normal menu-completion. The functions tt(accept-and-hold) and
 tt(accept-and-menu-complete) can be used to accept the match currently
 inserted and continue inserting matches after that. Matches inserted this
-way can be removed by invoking the tt(undo) function. Keys bound to one of
+way can be removed by invoking the tt(undo) function. The function
+tt(accept-and-infer-next-history) accepts the current match and
+immediatly tries completion with menu-selection again. In the case of
+files this allows one to select a directory and then to directly
+continue with completing files in it. Keys bound to one of
 the completion functions will cycle to the next (or, in case of
 tt(reverse-menu-complete), the previous) match, and the tt(redisplay) and
 tt(clear-screen) functions work as usual without leaving

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* accept-and-infer-next-history in path completion
  1999-07-07  8:23 PATCH: complist Sven Wischnowsky
@ 1999-07-09  7:47 ` Andrej Borsenkow
  0 siblings, 0 replies; 5+ messages in thread
From: Andrej Borsenkow @ 1999-07-09  7:47 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> This makes accept-and-infer-next-history be treated specially when in
> menu-selection. It accepts the current match and immediatly starts
> completion again. So if you have a list of files, place the mark on a
> directory and execute a-a-i-n-h, you can select files in that
> directory. Of course it would be nice to be able to go back again,
> e.g. with undo, but implementing that is a bit more complicated...
>

It just occured to me, that it is quite useful in path completion. E.g. if you
have something like

/tools/{share,src}/z/bla-bla-bla

it is nice to hit a single key to accept ``share'' or ``src'' and immediately
continue completion after that. In this case a-a-i-n-h is probably misnomer ...
something like accept-and-continue-completion would  be better.

/andrej


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: complist
@ 2000-05-22  8:42 Sven Wischnowsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-05-22  8:42 UTC (permalink / raw)
  To: zsh-workers


Here is the patch to make explanation strings be moved onto the screen 
again when the cursor approaches them from below.


This contains also the fix for what Bart wrote:

> This is with something close to the very latest patches ...
> 
> In the top zsh source directory:
> 
> zagzig[71] ls *<C-x e>
> 
> I now have a menu-selection with all-expansions first and then the individual
> files below that, and finally the original string below that.  My styles put
> the list of files in most-recently-modified order.
> 
> I typed TAB to move to the first file name (Completion), typed ^X TAB (which
> I have bound to accept-and-menu-complete) to get to Config, typed TAB to move
> on to Doc, typed ^X TAB again, and kaboom.

Weirdly, it didn't wrap around when looking for the current match.


There is also a hunk in _expand, fixing the test when the
all-expansions strings should use a display list instead of showing
the whole string.

Bye
 Sven

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.11
diff -u -r1.11 _expand
--- Completion/Core/_expand	2000/05/16 10:45:01	1.11
+++ Completion/Core/_expand	2000/05/22 08:40:18
@@ -111,7 +111,7 @@
   if _requested all-expansions expl 'all expansions'; then
     local disp dstr
 
-    if [[ $#exp -ge COLUMNS ]]; then
+    if [[ "${#${exp}}" -ge COLUMNS ]]; then
       disp=( -ld dstr )
       dstr=( "${(r:COLUMNS-5:)exp} ..." )
     else
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.17
diff -u -r1.17 complist.c
--- Src/Zle/complist.c	2000/05/16 10:45:26	1.17
+++ Src/Zle/complist.c	2000/05/22 08:40:19
@@ -390,6 +390,11 @@
 static Cmgroup *mgtab, *mgtabp;
 static struct listcols mcolors;
 
+/* Used in mtab/mgtab, for explanations. */
+
+#define mtexpl ((Cmatch *) 1)
+#define mgexpl ((Cmgroup) 1)
+
 /* Information for in-string colours. */
 
 static int nrefs;
@@ -977,7 +982,7 @@
 compprintlist(int showall)
 {
     static int lasttype = 0, lastbeg = 0, lastml = 0;
-    static lastn = 0, lastnl = 0;
+    static int lastn = 0, lastnl = 0, lastnlnct = -1;
     static Cmgroup lastg = NULL;
     static Cmatch *lastp = NULL;
     static Cexpl *lastexpl = NULL;
@@ -994,9 +999,11 @@
 	lastg = NULL;
 	lastexpl = NULL;
 	lastml = 0;
+	lastnlnct = -1;
     }
     cl = (listdat.nlines > lines - nlnct - mhasstat ?
-	  lines - nlnct - mhasstat : listdat.nlines) - 1;
+	  lines - nlnct - mhasstat : listdat.nlines) - (lastnlnct > nlnct);
+    lastnlnct = nlnct;
     mrestlines = lines - 1;
 
     if (cl < 2) {
@@ -1039,8 +1046,8 @@
 			int mm = (mcols * ml), i;
 
 			for (i = mcols; i--; ) {
-			    mtab[mm + i] = NULL;
-			    mgtab[mm + i] = NULL;
+			    mtab[mm + i] = mtexpl;
+			    mgtab[mm + i] = mgexpl;
 			}
 		    }
 		    if (stop)
@@ -1563,8 +1570,8 @@
 
     tab -= mcol;
 
-    for (p = wish; p >= 0 && !tab[p]; p--);
-    for (n = wish; n < mcols && !tab[n]; n++);
+    for (p = wish; p >= 0 && (!tab[p] || tab[p] == mtexpl); p--);
+    for (n = wish; n < mcols && (!tab[n] || tab[n] == mtexpl); n++);
     if (n == mcols)
 	n = -1;
 
@@ -1597,6 +1604,8 @@
     int cs, acc, nmatches, mline, mlbeg;
     struct menuinfo info;
     Cmgroup amatches, pmatches, lastmatches, lastlmatches;
+    char *origline;
+    int origcs, origll;
 };
 
 static int
@@ -1608,7 +1617,7 @@
     Thingy cmd;
     Menustack u = NULL;
     int i = 0, acc = 0, wishcol = 0, setwish = 0, oe = onlyexpl, wasnext = 0;
-    int space, lbeg = 0, step = 1, wrap, pl = nlnct;
+    int space, lbeg = 0, step = 1, wrap, pl = nlnct, broken = 0;
     char *s;
 
     if (fdat || (dummy && (!(s = getsparam("MENUSELECT")) ||
@@ -1649,7 +1658,7 @@
 
 	    for (y = 0; y < mlines; y++) {
 		for (x = mcols; x; x--, p++)
-		    if (*p && **p && mselect == (**p)->gnum)
+		    if (*p && *p != mtexpl && **p && mselect == (**p)->gnum)
 			break;
 		if (x)
 		    break;
@@ -1657,20 +1666,17 @@
 	    if (y < mlines)
 		mline = y;
 	}
-	space = lines - pl - mhasstat;
 	while (mline < mlbeg)
 	    if ((mlbeg -= step) < 0)
 		mlbeg = 0;
-#if 0
-	/* Attempt to ensure that the explanations for groups are scrolled
-	 * in. Doesn't work because there are other NULL fields. */
+
 	if (mlbeg && lbeg != mlbeg) {
 	    Cmatch **p = mtab + ((mlbeg - 1) * columns), **q;
 	    int c;
 
 	    while (mlbeg) {
 		for (q = p, c = columns; c; q++, c--)
-		    if (*q)
+		    if (*q && *q != mtexpl)
 			break;
 		if (c)
 		    break;
@@ -1678,10 +1684,10 @@
 		mlbeg--;
 	    }
 	}
-#endif
-	while (mline >= mlbeg + space)
-	    if ((mlbeg += step) + space > mlines)
-		mlbeg = mlines - space;
+	if ((space = lines - pl - mhasstat))
+	    while (mline >= mlbeg + space)
+		if ((mlbeg += step) + space > mlines)
+		    mlbeg = mlines - space;
 	if (lbeg != mlbeg) {
 	    Cmatch **p = mtab + (mlbeg * columns), **q;
 	    int c;
@@ -1701,8 +1707,10 @@
 	showinglist = -2;
 	zrefresh();
 	inselect = 1;
-	if (noselect)
+	if (noselect) {
+	    broken = 1;
 	    break;
+	}
 	selected = 1;
 	if (!i) {
 	    i = mcols * mlines;
@@ -1755,6 +1763,9 @@
 	    s->nbrbeg = nbrbeg;
 	    s->nbrend = nbrend;
 	    s->nmatches = nmatches;
+	    s->origline = origline;
+	    s->origcs = origcs;
+	    s->origll = origll;
 	    menucmp = menuacc = hasoldlist = 0;
 	    fixsuffix();
 	    validlist = 0;
@@ -1792,6 +1803,9 @@
 	    s->nbrbeg = nbrbeg;
 	    s->nbrend = nbrend;
 	    s->nmatches = nmatches;
+	    s->origline = origline;
+	    s->origcs = origcs;
+	    s->origll = origll;
 	    accept_last();
 	    do_menucmp(0);
 	    mselect = (*(minfo.cur))->gnum;
@@ -1805,7 +1819,10 @@
 			break;
 		if (mcol != mcols)
 		    break;
-		mline++;
+		if (++mline == mlines) {
+		    mline = 0;
+		    p -= mlines * mcols;
+		}
 	    } while (mline != ol);
 	    if (*p != minfo.cur) {
 		noselect = clearlist = listshown = 1;
@@ -1847,6 +1864,9 @@
 	    brend = dupbrinfo(u->brend, &lastbrend, 0);
 	    nbrbeg = u->nbrbeg;
 	    nbrend = u->nbrend;
+	    origline = u->origline;
+	    origcs = u->origcs;
+	    origll = u->origll;
 
 	    u = u->prev;
 	    clearlist = 1;
@@ -1888,7 +1908,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-	    } while (!*p);
+	    } while (!*p || *p == mtexpl);
 
 	    if (wrap == 1)
 		goto right;
@@ -1922,7 +1942,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-	    } while (!*p);
+	    } while (!*p || *p == mtexpl);
 
 	    if (wrap == 1)
 		goto left;
@@ -1946,7 +1966,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-		if (*p) {
+		if (*p && *p != mtexpl) {
 		    i--;
 		    lp = p;
 		    ll = mline;
@@ -1973,7 +1993,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-		if (*p) {
+		if (*p || *p != mtexpl) {
 		    i--;
 		    lp = p;
 		    ll = mline;
@@ -1994,7 +2014,7 @@
 		p -= mcols;
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-		if (*p) {
+		if (*p && *p != mtexpl) {
 		    lp = p;
 		    ll = mline;
 		}
@@ -2014,7 +2034,7 @@
 		p += mcols;
 		if (adjust_mcol(wishcol, &p, NULL))
 		    continue;
-		if (*p) {
+		if (*p && *p != mtexpl) {
 		    lp = p;
 		    ll = mline;
 		}
@@ -2046,7 +2066,7 @@
 		    mcol++;
 		    p++;
 		}
-	    } while (!*p || (mcol != omcol && *p == *op));
+	    } while (!*p || *p == mtexpl || (mcol != omcol && *p == *op));
 	    wishcol = mcol;
 
 	    if (wrap == 2)
@@ -2076,7 +2096,7 @@
 		    mcol--;
 		    p--;
 		}
-	    } while (!*p || (mcol != omcol && *p == *op));
+	    } while (!*p || *p == mtexpl || (mcol != omcol && *p == *op));
 	    wishcol = mcol;
 
 	    if (wrap == 2)
@@ -2087,7 +2107,7 @@
 		   cmd == Th(z_vibeginningofline)) {
 	    p -= mcol;
 	    mcol = 0;
-	    while (!*p) {
+	    while (!*p || *p == mtexpl) {
 		mcol++;
 		p++;
 	    }
@@ -2098,7 +2118,7 @@
 		   cmd == Th(z_viendofline)) {
 	    p += mcols - mcol - 1;
 	    mcol = mcols - 1;
-	    while (!*p) {
+	    while (!*p || *p == mtexpl) {
 		mcol--;
 		p--;
 	    }
@@ -2120,7 +2140,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, &pg))
 		    continue;
-	    } while (ol != mline && (*pg == g || !*pg));
+	    } while (ol != mline && (*pg == g || !*pg || *pg == mgexpl));
 	} else if (cmd == Th(z_vibackwardblankword)) {
 	    Cmgroup g = *pg;
 	    int ol = mline;
@@ -2137,7 +2157,7 @@
 		}
 		if (adjust_mcol(wishcol, &p, &pg))
 		    continue;
-	    } while (ol != mline && (*pg == g || !*pg));
+	    } while (ol != mline && (*pg == g || !*pg || *pg == mgexpl));
 	} else if (cmd == Th(z_completeword) ||
 		   cmd == Th(z_expandorcomplete) ||
 		   cmd == Th(z_expandorcompleteprefix) ||
@@ -2184,7 +2204,7 @@
 	menucmp = lastambig = hasoldlist = 0;
 	do_single(*(minfo.cur));
     }
-    if (wasnext) {
+    if (wasnext || broken) {
 	menucmp = 2;
 	showinglist = -2;
 	minfo.asked = 0;
@@ -2199,7 +2219,7 @@
     mlbeg = -1;
     fdat = NULL;
 
-    return (dat ? (acc ? 1 : 2) : (!noselect ^ acc));
+    return ((dat && !broken) ? (acc ? 1 : 2) : (!noselect ^ acc));
 }
 
 /* The widget function. */

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: PATCH: complist
  1999-07-09  8:56 PATCH: complist Sven Wischnowsky
@ 1999-07-09  9:55 ` Andrej Borsenkow
  0 siblings, 0 replies; 5+ messages in thread
From: Andrej Borsenkow @ 1999-07-09  9:55 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers


This fails for me. Starting at line 104 I have:

in place.  In the case of tt(accept-line), the match currently inserted
will be accepted and a new completion may be attempted.
Using tt(send-break) leaves menu-selection and continues with normal
menu-completion.  The functions tt(accept-and-hold) and

Do I miss some patches? I am pretty sure I have 'em all ... When is next release
slated?

> diff -u od/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
> --- od/Zsh/mod_complist.yo	Wed Jul  7 10:24:57 1999
> +++ Doc/Zsh/mod_complist.yo	Fri Jul  9 10:50:00 1999
> @@ -104,12 +104,12 @@
>  complete after it. Using tt(send-break) leaves menu-selection and
>  continues with normal menu-completion. The functions tt(accept-and-hold) and
>  tt(accept-and-menu-complete) can be used to accept the match currently
......

/andrej


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: complist
@ 1999-07-09  8:56 Sven Wischnowsky
  1999-07-09  9:55 ` Andrej Borsenkow
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 1999-07-09  8:56 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> This makes accept-and-infer-next-history be treated specially when in
> menu-selection. It accepts the current match and immediatly starts
> completion again. So if you have a list of files, place the mark on a
> directory and execute a-a-i-n-h, you can select files in that
> directory. Of course it would be nice to be able to go back again,
> e.g. with undo, but implementing that is a bit more complicated...

This does that. Now we have an ultra-light-weight file system
browser. Ouch.

The patch also fixes a display problem: if you were near the end of
the line and using menu-selection so that depending on the length of
the match inserted the prompt took one or two lines, the list was
moved down and up again, but the last line wasn't cleared when going
from a prompt spanning two lines to a prompt needing only one line.

The last line may now flicker again, but the rest should be ok (if
your terminal is fast enough).

Bye
 Sven

diff -u -r oos/Zle/complist.c Src/Zle/complist.c
--- oos/Zle/complist.c	Thu Jul  8 13:56:17 1999
+++ Src/Zle/complist.c	Fri Jul  9 10:40:10 1999
@@ -309,7 +309,7 @@
     Cexpl *e;
     int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0, opl = 0;
     int of = isset(LISTTYPES);
-    int mc, ml = 0, cc, hasm = 0;
+    int mc, ml = 0, cc, hasm = 0, cl;
     struct listcols col;
 
     if (minfo.asked == 2) {
@@ -448,7 +448,12 @@
 	mgtab = (Cmgroup *) zalloc(i * sizeof(Cmgroup));
 	memset(mgtab, 0, i * sizeof(Cmgroup));
 	mcols = ncols;
-	mlines = nlines;
+	mlines = cl = nlines;
+	if (cl < 2) {
+	    cl = -1;
+	    if (tccan(TCCLEAREOD))
+		tcout(TCCLEAREOD);
+	}
     }
     /* Now print the matches. */
     g = amatches;
@@ -456,14 +461,27 @@
 	char **pp = g->ylist;
 
 	if ((e = g->expls)) {
+	    int l;
+
 	    while (*e) {
 		if ((*e)->count) {
 		    if (pnl) {
 			putc('\n', shout);
 			pnl = 0;
 			ml++;
+			if (cl >= 0 && --cl <= 1) {
+			    cl = -1;
+			    if (tccan(TCCLEAREOD))
+				tcout(TCCLEAREOD);
+			}
+		    }
+		    l = printfmt((*e)->str, (*e)->count, 1);
+		    ml += l;
+		    if (cl >= 0 && (cl -= l) <= 1) {
+			cl = -1;
+			if (tccan(TCCLEAREOD))
+			    tcout(TCCLEAREOD);
 		    }
-		    ml += printfmt((*e)->str, (*e)->count, 1);
 		    pnl = 1;
 		}
 		e++;
@@ -474,6 +492,11 @@
 		putc('\n', shout);
 		pnl = 0;
 		ml++;
+		if (cl >= 0 && --cl <= 1) {
+		    cl = -1;
+		    if (tccan(TCCLEAREOD))
+			tcout(TCCLEAREOD);
+		}
 	    }
 	    if (g->flags & CGF_LINES) {
 		while (*pp) {
@@ -504,6 +527,11 @@
 		    if (n) {
 			putc('\n', shout);
 			ml++;
+			if (cl >= 0 && --cl <= 1) {
+			    cl = -1;
+			    if (tccan(TCCLEAREOD))
+				tcout(TCCLEAREOD);
+			}
 		    }
 		    pp++;
 		}
@@ -517,6 +545,11 @@
 		putc('\n', shout);
 		pnl = 0;
 		ml++;
+		if (cl >= 0 && --cl <= 1) {
+		    cl = -1;
+		    if (tccan(TCCLEAREOD))
+			tcout(TCCLEAREOD);
+		}
 	    }
 	    for (p = skipnolist(g->matches); n && nl--;) {
 		i = ncols;
@@ -607,6 +640,11 @@
 		if (n) {
 		    putc('\n', shout);
 		    ml++;
+		    if (cl >= 0 && --cl <= 1) {
+			cl = -1;
+			if (tccan(TCCLEAREOD))
+			    tcout(TCCLEAREOD);
+		    }
 		    if (n && nl)
 			p = skipnolist(p + 1);
 		}
@@ -640,6 +678,7 @@
     char *line;
     int cs;
     struct menuinfo info;
+    Cmgroup amatches, pmatches, lmatches;
 };
 
 static int
@@ -693,8 +732,20 @@
 	    acc = 1;
 	    break;
 	} else if (cmd == Th(z_acceptandinfernexthistory)) {
+	    Menustack s = (Menustack) zhalloc(sizeof(*s));
+
+	    s->prev = u;
+	    u = s;
+	    s->line = dupstring((char *) line);
+	    s->cs = cs;
+	    memcpy(&(s->info), &minfo, sizeof(struct menuinfo));
+	    s->amatches = amatches;
+	    s->pmatches = pmatches;
+	    s->lmatches = lmatches;
 	    menucmp = 0;
 	    fixsuffix();
+	    validlist = 0;
+	    pmatches = NULL;
 	    invalidatelist();
 	    menucomplete(zlenoargs);
 	    if (dat->num < 2 || !minfo.cur || !*(minfo.cur)) {
@@ -704,8 +755,6 @@
 		break;
 	    }
 	    clearlist = 1;
-	    zrefresh();
-	    clearlist = 0;
 	    mselect = (*(minfo.cur))->gnum;
 	    continue;
 	} else if (cmd == Th(z_acceptandhold) ||
@@ -717,6 +766,7 @@
 	    s->line = dupstring((char *) line);
 	    s->cs = cs;
 	    memcpy(&(s->info), &minfo, sizeof(struct menuinfo));
+	    s->amatches = s->pmatches = s->lmatches = NULL;
 	    acceptlast();
 	    do_menucmp(0);
 	    mselect = (*(minfo.cur))->gnum;
@@ -734,7 +784,15 @@
 	    cs = u->cs;
 	    memcpy(&minfo, &(u->info), sizeof(struct menuinfo));
 	    p = &(minfo.cur);
+	    if (u->pmatches && pmatches != u->pmatches) {
+		freematches();
+		amatches = u->amatches;
+		pmatches = u->pmatches;
+		lmatches = u->lmatches;
+		hasperm = 1;
+	    }
 	    u = u->prev;
+	    clearlist = 1;
 	} else if (cmd == Th(z_redisplay)) {
 	    redisplay(zlenoargs);
 	    continue;
@@ -867,6 +925,19 @@
 	}
 	do_single(**p);
 	mselect = (**p)->gnum;
+    }
+    if (u) {
+	int hp = hasperm;
+	Cmgroup m = pmatches;
+
+	for (; u; u = u->prev) {
+	    if (u->pmatches != m) {
+		pmatches = u->pmatches;
+		freematches();
+	    }
+	}
+	pmatches = m;
+	hasperm = hp;
     }
     selectlocalmap(NULL);
     mselect = -1;
diff -u -r oos/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- oos/Zle/zle_tricky.c	Thu Jul  8 11:11:38 1999
+++ Src/Zle/zle_tricky.c	Fri Jul  9 10:36:17 1999
@@ -133,7 +133,8 @@
 /* This holds the list of matches-groups. lmatches is a pointer to the  *
  * last element in this list. */
 
-static Cmgroup pmatches, amatches, lmatches;
+/**/
+Cmgroup pmatches, amatches, lmatches;
 
 /* Non-zero if we have permanently allocated matches. */
 
@@ -150,7 +151,8 @@
 
 /* !=0 if we have a valid completion list. */
 
-static int validlist;
+/**/
+int validlist;
 
 /* This flag is non-zero if we are completing a pattern (with globcomplete) */
 
@@ -7041,7 +7043,7 @@
 /* This frees the groups of matches. */
 
 /**/
-static void
+void
 freematches(void)
 {
     Cmgroup g = pmatches, n;
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo	Wed Jul  7 10:24:56 1999
+++ Doc/Zsh/compsys.yo	Thu Jul  8 08:58:06 1999
@@ -579,7 +579,10 @@
 tt(_oldlist) completer).  If it is unset, or any other value, then the
 existing list of completions will be displayed if it is not already;
 otherwise, the standard completion list will be generated:  this is the
-default behaviour of tt(_oldlist).
+default behaviour of tt(_oldlist). However, if there is an old list
+and this key contains the name of the completer function that
+generated the list, then the old list will be used even if it was
+generated by a widget which does not listing.
 
 For example, suppose you type tt(^Xc) to use the tt(_correct_word)
 widget, which generates a list of corrections for the word under the
@@ -587,6 +590,14 @@
 completions for the word on the command line, and show that.  With
 tt(_oldlist), it will instead show the list of corrections already
 generated.
+
+As another example consider the tt(_match) completer: with the
+tt(match_insert) key set to tt(unambig) it inserts only an
+unambiguous prefix string if there is any. But since this may remove
+parts of the original pattern, attempting completion again may result
+in more matches than on the first attempt. But by using the
+tt(_oldlist) completer and setting this key to tt(_match), the list of 
+matches generated on the first attempt will be used again.
 )
 item(tt(oldlist_menu))(
 Controls how menu completion behaves when a completion has already been
diff -u od/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
--- od/Zsh/mod_complist.yo	Wed Jul  7 10:24:57 1999
+++ Doc/Zsh/mod_complist.yo	Fri Jul  9 10:50:00 1999
@@ -104,12 +104,12 @@
 complete after it. Using tt(send-break) leaves menu-selection and
 continues with normal menu-completion. The functions tt(accept-and-hold) and
 tt(accept-and-menu-complete) can be used to accept the match currently
-inserted and continue inserting matches after that. Matches inserted this
-way can be removed by invoking the tt(undo) function. The function
+inserted and continue inserting matches after that. The function
 tt(accept-and-infer-next-history) accepts the current match and
 immediatly tries completion with menu-selection again. In the case of
 files this allows one to select a directory and then to directly
-continue with completing files in it. Keys bound to one of
+continue with completing files in it. Matches inserted in one of these
+ways can be removed by invoking the tt(undo) function. Keys bound to one of
 the completion functions will cycle to the next (or, in case of
 tt(reverse-menu-complete), the previous) match, and the tt(redisplay) and
 tt(clear-screen) functions work as usual without leaving

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-05-22  8:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-07  8:23 PATCH: complist Sven Wischnowsky
1999-07-09  7:47 ` accept-and-infer-next-history in path completion Andrej Borsenkow
1999-07-09  8:56 PATCH: complist Sven Wischnowsky
1999-07-09  9:55 ` Andrej Borsenkow
2000-05-22  8:42 Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).