From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9143 invoked from network); 19 Jul 1999 13:39:59 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 Jul 1999 13:39:59 -0000 Received: (qmail 3587 invoked by alias); 19 Jul 1999 13:39:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7196 Received: (qmail 3579 invoked from network); 19 Jul 1999 13:39:51 -0000 Date: Mon, 19 Jul 1999 15:39:48 +0200 (MET DST) Message-Id: <199907191339.PAA03026@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 18 Jul 1999 10:39:08 +0900 Subject: Re: completion problem with matching control. Tanaka Akira wrote: > I found a problem about completion with matching control. > > Z:akr@is27e1u11% zsh-3.1.6-test-1 -f > is27e1u11% autoload -U compinit > is27e1u11% compinit -D > is27e1u11% _tst () { compadd -P b A; compadd -P c A } > is27e1u11% compdef -a _tst tst > is27e1u11% compctl -M m:\{a-z\}\=\{A-Z\} > is27e1u11% tst a > > Then, "a" is deleted. The problem is in the different -P prefixes, not in the matching. The completion code stuffed all prefixes and all suffixes together and adds them to the string itself, so that things still work even if for one match a string-part is in one prefix and for another match the same string is in a different prefix. However, -P is slightly different since it doesn't `come from the line'. So this patch tries to keep the old behavior if possible and otherwise adds the prefixes one by one. Bye Sven diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c --- os/Zle/zle_tricky.c Thu Jul 15 16:01:50 1999 +++ Src/Zle/zle_tricky.c Mon Jul 19 15:38:54 1999 @@ -3527,7 +3527,9 @@ p->next = qsl; } } - /* And the same for the prefix. */ + /* The prefix is handled differently because the completion code + * is much more eager to insert the -P prefix than it is to insert + * the -S suffix. */ if (qipre) palen = (qipl = strlen(qipre)); if (ipre) @@ -3537,7 +3539,49 @@ if (ppre) palen += (ppl = strlen(ppre)); - if (palen) { + if (pl) { + if (ppl) { + Cline lp, p = bld_parts(ppre, ppl, ppl, &lp); + + if (lp->prefix && !(line->flags & (CLF_SUF | CLF_MID))) { + lp->prefix->next = line->prefix; + line->prefix = lp->prefix; + lp->prefix = NULL; + + free_cline(lp); + + if (p != lp) { + Cline q; + + for (q = p; q->next != lp; q = q->next); + + q->next = line; + line = p; + } + } else { + lp->next = line; + line = p; + } + } + if (pl) { + Cline lp, p = bld_parts(pre, pl, pl, &lp); + + lp->next = line; + line = p; + } + if (ipl) { + Cline lp, p = bld_parts(ipre, ipl, ipl, &lp); + + lp->next = line; + line = p; + } + if (qipl) { + Cline lp, p = bld_parts(qipre, qipl, qipl, &lp); + + lp->next = line; + line = p; + } + } else if (palen) { char *apre = (char *) zhalloc(palen); Cline p, lp; -- Sven Wischnowsky wischnow@informatik.hu-berlin.de