Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: widget special PREFIX variable and cursor position with complete_in_word



Yuri D'Elia wrote:
> On 02/26/2014 09:15 AM, Yuri D'Elia wrote:
> > I also noticed so far that it fails for = like you said, and # too.

# works fine in my testing. As do < and > but it is probably wise to
quote them anyway.

> It occurred to me that maybe = is incorrectly used literally for tokenization inside complist.
> Could somebody look if the string is tokenized correctly?

You're right. The complist code is splitting on =. With the following
patch, the = can be matched. This allows a \= or plain = if it is
inside (...). Any thoughts on if that's right?

Oliver

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index b852ee9..5e5ba9f 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -383,12 +383,25 @@ getcoldef(char *s)
     } else if (*s == '=') {
 	char *p = ++s, *t, *cols[MAX_POS];
 	int ncols = 0;
+	int nesting = 0;
 	Patprog prog;
 
 	/* This is for a pattern. */
 
-	while (*s && *s != '=')
-	    s++;
+	while (*s && (nesting || *s != '=')) {
+	    switch (*s++) {
+		case '\\':
+		    if (*s)
+			s++;
+		    break;
+		case '(':
+		    nesting++;
+		    break;
+		case ')':
+		    nesting--;
+		    break;
+	    }
+	}
 	if (!*s)
 	    return s;
 	*s++ = '\0';



Messages sorted by: Reverse Date, Date, Thread, Author