zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@math.gatech.edu
Subject: Re: cdablevars and cd completion in 3.1.5
Date: Thu, 3 Dec 1998 11:17:45 +0100 (MET)	[thread overview]
Message-ID: <199812031017.LAA14592@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 1 Dec 1998 10:09:55 -0800


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


             reply	other threads:[~1998-12-03 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-03 10:17 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-12-07 11:58 Sven Wischnowsky
1998-12-01 12:52 Sven Wischnowsky
1998-12-01 18:09 ` Bart Schaefer

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=199812031017.LAA14592@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).