zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: completion cannot be used recursively (yet)
@ 2001-01-18 14:38 Sven Wischnowsky
  0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2001-01-18 14:38 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> With the current CVS (I rpesume, after the last signal queueing patch) I get
> this when attempting to use accept-and-menu-complete in menu selection:
> 
> bor@itsrm2% cd /u2/sni/mr/RMS/
> zsh: completion cannot be used recursively (yet)

Oops. Yes, we have to allow a controlled form of recursive completion
attempts.

The patch also contains a fix so that freematches() doesn't
unconditionally unset minfo.cur (the pointer to the currently inserted 
match). That was caused by my patch for Peter's 13322 (hope that still 
works, Peter?).


Bye
 Sven

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.43
diff -u -r1.43 compcore.c
--- Src/Zle/compcore.c	2001/01/16 13:44:20	1.43
+++ Src/Zle/compcore.c	2001/01/18 14:33:49
@@ -934,7 +934,7 @@
 	    amatches = lastmatches;
 	    lmatches = lastlmatches;
 	    if (pmatches) {
-		freematches(pmatches);
+		freematches(pmatches, 1);
 		pmatches = NULL;
 		hasperm = 0;
 	    }
@@ -943,7 +943,7 @@
 	    return 0;
 	}
 	if (lastmatches) {
-	    freematches(lastmatches);
+	    freematches(lastmatches, 1);
 	    lastmatches = NULL;
 	}
 	permmatches(1);
@@ -2793,7 +2793,7 @@
 
 	    if (g->perm) {
 		g->perm->next = NULL;
-		freematches(g->perm);
+		freematches(g->perm, 0);
 	    }
 	    g->perm = n;
 
@@ -2909,7 +2909,7 @@
 
 /**/
 mod_export void
-freematches(Cmgroup g)
+freematches(Cmgroup g, int cm)
 {
     Cmgroup n;
     Cmatch *m;
@@ -2938,5 +2938,6 @@
 
 	g = n;
     }
-    minfo.cur = NULL;
+    if (cm)
+	minfo.cur = NULL;
 }
Index: Src/Zle/compctl.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compctl.c,v
retrieving revision 1.8
diff -u -r1.8 compctl.c
--- Src/Zle/compctl.c	2001/01/16 12:39:22	1.8
+++ Src/Zle/compctl.c	2001/01/18 14:33:51
@@ -1848,7 +1848,7 @@
 	    amatches = lastmatches;
 	    lmatches = lastlmatches;
 	    if (pmatches) {
-		freematches(pmatches);
+		freematches(pmatches, 1);
 		pmatches = NULL;
 		hasperm = 0;
 	    }
@@ -1858,7 +1858,7 @@
 	    return 0;
 	}
 	if (lastmatches) {
-	    freematches(lastmatches);
+	    freematches(lastmatches, 1);
 	    lastmatches = NULL;
 	}
 	permmatches(1);
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.38
diff -u -r1.38 complist.c
--- Src/Zle/complist.c	2001/01/16 13:44:20	1.38
+++ Src/Zle/complist.c	2001/01/18 14:33:51
@@ -1812,6 +1812,7 @@
 	    amatches = pmatches = lastmatches = NULL;
 	    invalidate_list();
 	    iforcemenu = 1;
+	    comprecursive = 1;
 	    menucomplete(zlenoargs);
 	    iforcemenu = 0;
 
@@ -1865,6 +1866,7 @@
 	    s->origll = origll;
 	    accept_last();
 	    handleundo();
+	    comprecursive = 1;
 	    do_menucmp(0);
 	    mselect = (*(minfo.cur))->gnum;
 
@@ -1909,7 +1911,7 @@
 	    mlbeg = u->mlbeg;
 	    if (u->lastmatches && lastmatches != u->lastmatches) {
 		if (lastmatches)
-		    freematches(lastmatches);
+		    freematches(lastmatches, 0);
 		amatches = u->amatches;
 		pmatches = u->pmatches;
 		lastmatches = u->lastmatches;
@@ -2236,6 +2238,7 @@
 		   !strcmp(cmd->nam, "expand-or-complete-prefix") ||
 		   !strcmp(cmd->nam, "menu-complete") ||
 		   !strcmp(cmd->nam, "menu-expand-or-complete")) {
+	    comprecursive = 1;
 	    do_menucmp(0);
 	    mselect = (*(minfo.cur))->gnum;
 	    setwish = 1;
@@ -2243,6 +2246,7 @@
 	    continue;
 	} else if (cmd == Th(z_reversemenucomplete) ||
 		   !strcmp(cmd->nam, "reverse-menu-complete")) {
+	    comprecursive = 1;
 	    reversemenucomplete(zlenoargs);
 	    mselect = (*(minfo.cur))->gnum;
 	    setwish = 1;
@@ -2265,7 +2269,7 @@
     if (u)
 	for (; u; u = u->prev)
 	    if (u->lastmatches != lastmatches)
-		freematches(u->lastmatches);
+		freematches(u->lastmatches, 0);
 
     selectlocalmap(NULL);
     mselect = mlastcols = mlastlines = -1;
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.32
diff -u -r1.32 compresult.c
--- Src/Zle/compresult.c	2001/01/15 10:44:15	1.32
+++ Src/Zle/compresult.c	2001/01/18 14:33:52
@@ -2206,7 +2206,7 @@
     if (validlist) {
 	if (showinglist == -2)
 	    zrefresh();
-	freematches(lastmatches);
+	freematches(lastmatches, 1);
 	lastmatches = NULL;
 	hasoldlist = 0;
     }
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.15
diff -u -r1.15 zle_main.c
--- Src/Zle/zle_main.c	2001/01/16 13:44:20	1.15
+++ Src/Zle/zle_main.c	2001/01/18 14:33:52
@@ -1129,6 +1129,7 @@
     /* miscellaneous initialisations */
     stackhist = stackcs = -1;
     kungetbuf = (char *) zalloc(kungetsz = 32);
+    comprecursive = 0;
 
     /* initialise the keymap system */
     init_keymaps();
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.22
diff -u -r1.22 zle_tricky.c
--- Src/Zle/zle_tricky.c	2001/01/16 13:44:20	1.22
+++ Src/Zle/zle_tricky.c	2001/01/18 14:33:53
@@ -145,6 +145,11 @@
 /**/
 mod_export int cfret;
 
+/* != 0 if recursive calls to completion are (temporarily) allowed */
+
+/**/
+mod_export int comprecursive;
+
 /* Find out if we have to insert a tab (instead of trying to complete). */
 
 /**/
@@ -540,11 +545,12 @@
     char *s, *ol;
     int olst = lst, chl = 0, ne = noerrs, ocs, ret = 0, dat[2];
 
-    if (active) {
+    if (active && !comprecursive) {
 	zwarn("completion cannot be used recursively (yet)", NULL, 0);
 	return 1;
     }
     active = 1;
+    comprecursive = 0;
     if (undoing)
 	setlastline();
 

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-18 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-18 14:38 PATCH: Re: completion cannot be used recursively (yet) 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).