From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13932 invoked from network); 3 Dec 1998 10:36:27 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 3 Dec 1998 10:36:27 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id FAA14616; Thu, 3 Dec 1998 05:19:28 -0500 (EST) Resent-Date: Thu, 3 Dec 1998 05:19:28 -0500 (EST) Date: Thu, 3 Dec 1998 11:17:45 +0100 (MET) Message-Id: <199812031017.LAA14592@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@math.gatech.edu In-reply-to: "Bart Schaefer"'s message of Tue, 1 Dec 1998 10:09:55 -0800 Subject: Re: cdablevars and cd completion in 3.1.5 Resent-Message-ID: <"I41_W2.0.Ga3.mMcPs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4698 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart Schaefer wrote: > ... > > If the current word can't be completed because of the position of the > cursor, then shouldn't the position of the cursor also determine whether > the pattern matches the word in the first place? Why would you ever > WANT a pattern to match and then NOT call the corresponding completion? Not wanting to reply `yes, I agree' without being able to offer you a patch, I waited until now... The patch below makes `-x'-patterns match only if the cursor is not in the ignored part of the current word. This affect only `s[...]', `S[...]', `n[...]', and `N[...]'. It does NOT affect `c[0,...]' or `w[...]'. The patch also fixes re-inserting ignored prefixes that need quoting. This one goes on top of the patch (4697) I just send (and you'll need that one). Bye Sven *** os/Zle/zle_tricky.c Thu Dec 3 09:17:12 1998 --- Src/Zle/zle_tricky.c Thu Dec 3 11:04:31 1998 *************** *** 2281,2287 **** int l, r = 0, ocs, a = cs; if (m->ipre) { ! inststrlen(m->ipre, 1, (l = strlen(m->ipre))); r += l; } if (m->pre) { --- 2281,2289 ---- int l, r = 0, ocs, a = cs; if (m->ipre) { ! char *p = quotename(m->ipre, NULL, NULL, NULL); ! ! inststrlen(p, 1, (l = strlen(p))); r += l; } if (m->pre) { *************** *** 2718,2735 **** /**/ static int ! getcpat(char *wrd, int cpatindex, char *cpat, int class) { ! char *str, *s, *t, *p; int d = 0; ! if (!wrd || !*wrd) return -1; cpat = rembslash(cpat); - str = ztrdup(wrd); - untokenize(str); if (!cpatindex) cpatindex++, d = 0; else if ((d = (cpatindex < 0))) --- 2720,2735 ---- /**/ static int ! getcpat(char *str, int cpatindex, char *cpat, int class) { ! char *s, *t, *p; int d = 0; ! if (!str || !*str) return -1; cpat = rembslash(cpat); if (!cpatindex) cpatindex++, d = 0; else if ((d = (cpatindex < 0))) *************** *** 2740,2762 **** d ? s-- : s++) { for (t = s, p = cpat; *t && *p; p++) { if (class) { ! if (*p == *s && !--cpatindex) { ! zsfree(str); return (int)(s - str + 1); - } } else if (*t++ != *p) break; } ! if (!class && !*p && !--cpatindex) { ! zsfree(str); ! t += wrd - str; ! for (d = 0; --t >= wrd;) ! if (! INULL(*t)) ! d++; ! return d; ! } } - zsfree(str); return -1; } --- 2740,2753 ---- d ? s-- : s++) { for (t = s, p = cpat; *t && *p; p++) { if (class) { ! if (*p == *s && !--cpatindex) return (int)(s - str + 1); } else if (*t++ != *p) break; } ! if (!class && !*p && !--cpatindex) ! return t - str; } return -1; } *************** *** 3322,3329 **** break; case CCT_CURSUF: case CCT_CURPRE: ! s = ztrdup(clwpos < clwnum ? clwords[clwpos] : ""); untokenize(s); sc = rembslash(cc->u.s.s[i]); a = strlen(sc); if (!strncmp(s, sc, a)) { --- 3313,3321 ---- break; case CCT_CURSUF: case CCT_CURPRE: ! s = ztrdup(clwpos < clwnum ? os : ""); untokenize(s); + if (isset(COMPLETEINWORD)) s[offs] = '\0'; sc = rembslash(cc->u.s.s[i]); a = strlen(sc); if (!strncmp(s, sc, a)) { *************** *** 3336,3342 **** if (clwpos < 0 || clwpos >= clwnum) t = 0; else { ! a = getcpat(clwords[clwpos], cc->u.s.p[i], cc->u.s.s[i], cc->type == CCT_CURSUBC); --- 3328,3337 ---- if (clwpos < 0 || clwpos >= clwnum) t = 0; else { ! s = ztrdup(os); ! untokenize(s); ! if (isset(COMPLETEINWORD)) s[offs] = '\0'; ! a = getcpat(s, cc->u.s.p[i], cc->u.s.s[i], cc->type == CCT_CURSUBC); *************** *** 4819,4825 **** * to insert any unambiguous prefix and suffix, if possible. */ if (ainfo->iprefix && *ainfo->iprefix) { ! inststrlen(ainfo->iprefix, 1, -1); inststrlen(ainfo->pprefix, 1, -1); ps = ainfo->iaprefix; lc = ainfo->ilinecl; --- 4814,4820 ---- * to insert any unambiguous prefix and suffix, if possible. */ if (ainfo->iprefix && *ainfo->iprefix) { ! inststrlen(quotename(ainfo->iprefix, NULL, NULL, NULL), 1, -1); inststrlen(ainfo->pprefix, 1, -1); ps = ainfo->iaprefix; lc = ainfo->ilinecl; -- Sven Wischnowsky wischnow@informatik.hu-berlin.de