From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25886 invoked from network); 18 Jan 2001 14:39:20 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Jan 2001 14:39:20 -0000 Received: (qmail 4310 invoked by alias); 18 Jan 2001 14:39:13 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13374 Received: (qmail 4299 invoked from network); 18 Jan 2001 14:39:13 -0000 Date: Thu, 18 Jan 2001 15:38:57 +0100 (MET) Message-Id: <200101181438.PAA12804@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Andrej Borsenkow"'s message of Thu, 18 Jan 2001 15:21:29 +0300 Subject: PATCH: Re: completion cannot be used recursively (yet) 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