zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: _approximate and _path_files
Date: Thu, 16 Dec 1999 09:42:26 +0100 (MET)	[thread overview]
Message-ID: <199912160842.JAA11997@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Wed, 15 Dec 1999 14:16:21 +0300


Andrej Borsenkow wrote:

> Do they work together? Assuming that I have directory /archive/sni/mr,
> 
> cd /archive; l sin<TAB>
> 
> gives me `sni'
> 
> but simple
> 
> l /ar/sin<TAB>
> 
> after *very* long time beeps.
> 
> If not - it's really a pity.

This is as far as I could think yesterday evening. It makes the code
explicitly move globbing flags after the prefix if that could be
matched. It is probably not perfect and not very clean, but since *do* 
explicitly match the prefix (and suffix) since some time it's probably 
ok to make it handle globbing flags this way.

Dunno if I ever find a better way... 

Bye
 Sven

diff -ru ../z.old/Src/Zle/compcore.c Src/Zle/compcore.c
--- ../z.old/Src/Zle/compcore.c	Thu Dec 16 09:28:46 1999
+++ Src/Zle/compcore.c	Thu Dec 16 09:36:53 1999
@@ -1662,8 +1662,26 @@
 	    } else
 		lsl = 0;
 	    if (dat->aflags & CAF_MATCH) {
-		int ml;
+		int ml, gfl = 0;
+		char *globflag = NULL;
 
+		if (comppatmatch && *comppatmatch &&
+		    dat->ppre && lpre[0] == '(' && lpre[1] == '#') {
+		    char *p;
+
+		    for (p = lpre + 2; *p && *p != ')'; p++);
+
+		    if (*p == ')') {
+			char sav = p[1];
+
+			p[1] = '\0';
+			globflag = dupstring(lpre);
+			gfl = p - lpre + 1;
+			p[1] = sav;
+
+			lpre = p + 1;
+		    }
+		}
 		s = dat->ppre ? dat->ppre : "";
 		if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
 		    if (matchsubs) {
@@ -1688,11 +1706,11 @@
 			*argv = NULL;
 		    bcp = lpl;
 		}
-
 		s = dat->psuf ? dat->psuf : "";
 		if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
 		    if (matchsubs) {
-			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0,
+					      CLF_SUF);
 
 			tmp->suffix = matchsubs;
 			if (matchlastpart)
@@ -1715,17 +1733,21 @@
 		}
 		if (comppatmatch && *comppatmatch) {
 		    int is = (*comppatmatch == '*');
-		    char *tmp = (char *) zhalloc(2 + llpl + llsl);
+		    char *tmp = (char *) zhalloc(2 + llpl + llsl + gfl);
 
-		    strcpy(tmp, lpre);
-		    tmp[llpl] = 'x';
-		    strcpy(tmp + llpl + is, lsuf);
+		    if (gfl) {
+			strcpy(tmp, globflag);
+			strcat(tmp, lpre);
+		    } else
+			strcpy(tmp, lpre);
+		    tmp[llpl + gfl] = 'x';
+		    strcpy(tmp + llpl + gfl + is, lsuf);
 
 		    tokenize(tmp);
 		    remnulargs(tmp);
 		    if (haswilds(tmp)) {
 			if (is)
-			    tmp[llpl] = Star;
+			    tmp[llpl + gfl] = Star;
 			if ((cp = patcompile(tmp, 0, NULL)))
 			    haspattern = 1;
 		    }

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~1999-12-16  8:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=199912160842.JAA11997@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).