zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: completion cannot be used recursively (yet)
Date: Thu, 18 Jan 2001 15:38:57 +0100 (MET)	[thread overview]
Message-ID: <200101181438.PAA12804@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Thu, 18 Jan 2001 15:21:29 +0300


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


                 reply	other threads:[~2001-01-18 14:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200101181438.PAA12804@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).