zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: help with _match, globcomplete etc.
Date: Tue, 15 Feb 2000 17:08:37 +0100 (MET)	[thread overview]
Message-ID: <200002151608.RAA14415@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Oliver Kiddle's message of Tue, 15 Feb 2000 11:09:18 +0000


Oliver Kiddle wrote:

> ...
>
> so that ^X$ wouldn't also glob complete but it comes back with any glob
> characters quoted. It seems that expand-word always does this when
> noglob is set. Surely this isn't right? In the process, I also noticed
> that the quoting can go slightly wrong if there are opened but not
> closed braces: $code[ai]/{a,b<Ctrl-X,*> comes back with a quoted '[' in
> the middle.

Hm. It's the call to quotename() in zle_tricky.c:1649. I'm pretty sure 
this is intended to make things work when the words resulting from
parameter expansion or globbing contains characters that need to be
quoted.

Trying to fix that would be very hard... we would have to find out
which part comes from the expansion and which doesn't or maybe being
more careful with (un)tokenization()... so, no patch for this.

However, it also removed parts of the string in cases like the example --
brace expansions. That's due to the in-brace completion stuff. The
patch fixes this in the simplest way I could thnik of: keep a
unaltered copy of the word an let expansion work on that.

I couldn't reproduce your `[' problem, unless that was a typo and you
meant a quoted `{'. In this case it's the same as for the quoted
globbing characters.

Bye
 Sven

P.S.:   The difference between the not-fixed and the fixed part is
        that I didn't write the former and hence don't really feel
        responsible ;-)

P.P.S.: Yes, there are parts of zle_tricky.c I didn't write.

diff -ru ../z.old/Src/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- ../z.old/Src/Zle/zle_tricky.c	Tue Feb 15 13:21:40 2000
+++ Src/Zle/zle_tricky.c	Tue Feb 15 16:55:11 2000
@@ -108,6 +108,10 @@
 
 static char *qword;
 
+/* This holds the word we are working on without braces removed. */
+
+static char *origword;
+
 /* The quoted prefix/suffix and a flag saying if we want to add the
  * closing quote. */
 
@@ -685,17 +689,17 @@
 	    inwhat = IN_CMD;
 
 	if (lst == COMP_SPELL) {
-	    char *x, *q, *ox;
+	    char *w = dupstring(origword), *x, *q, *ox;
 
-	    for (q = s; *q; q++)
+	    for (q = w; *q; q++)
 		if (INULL(*q))
 		    *q = Nularg;
 	    cs = wb;
 	    foredel(we - wb);
 	    HEAPALLOC {
-		untokenize(x = ox = dupstring(s));
-		if (*s == Tilde || *s == Equals || *s == String)
-		    *x = *s;
+		untokenize(x = ox = dupstring(w));
+		if (*w == Tilde || *w == Equals || *w == String)
+		    *x = *w;
 		spckword(&x, 0, lincmd, 0);
 		ret = !strcmp(x, ox);
 	    } LASTALLOC;
@@ -708,7 +712,7 @@
 	    int ocs = cs, ne = noerrs;
 
 	    noerrs = 1;
-	    ret = doexpansion(s, lst, olst, lincmd);
+	    ret = doexpansion(origword, lst, olst, lincmd);
 	    lastambig = 0;
 	    noerrs = ne;
 
@@ -1329,6 +1333,9 @@
 		chuck(p--);
 	    }
 
+	zsfree(origword);
+	origword = ztrdup(s);
+
 	if (!isset(IGNOREBRACES)) {
 	    /* Try and deal with foo{xxx etc. */
 	    char *curs = s + (isset(COMPLETEINWORD) ? offs : strlen(s));
@@ -1353,8 +1360,8 @@
 			    break;
 			}
 			i += tp - p;
-			p = tp;
 			dp += tp - p;
+			p = tp;
 		    } else {
 			char *tp = p + 1;
 
@@ -1385,8 +1392,8 @@
 			    }
 			    tp--;
 			    i += tp - p;
-			    p = tp;
 			    dp += tp - p;
+			    p = tp;
 			}
 		    }
 		} else if (p < curs) {

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


             reply	other threads:[~2000-02-15 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-15 16:08 Sven Wischnowsky [this message]
2000-02-15 19:53 ` help with _match, globcomplete etc. (with a PATCH) Oliver Kiddle
2000-02-16  6:47   ` Bart Schaefer
2000-02-16 10:38     ` Oliver Kiddle
2000-02-16 11:52       ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-02-15 11:34 help with _match, globcomplete etc Sven Wischnowsky
2000-02-14 13:03 help with _match, globcomplete etc. (with PATCH) Sven Wischnowsky
2000-02-15 11:09 ` help with _match, globcomplete etc Oliver Kiddle
2000-02-08 14:28 Problem with completion after a variable with globcomplete Sven Wischnowsky
2000-02-14 12:23 ` help with _match, globcomplete etc Oliver Kiddle

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=200002151608.RAA14415@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).