zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: completion problem with matching control.
Date: Mon, 19 Jul 1999 15:39:48 +0200 (MET DST)	[thread overview]
Message-ID: <199907191339.PAA03026@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 18 Jul 1999 10:39:08 +0900


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<TAB>
> 
> 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


             reply	other threads:[~1999-07-19 13:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-19 13:39 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-07-18  1:39 Tanaka Akira

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=199907191339.PAA03026@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).