Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug in { completion's comma removal
- X-seq: zsh-workers 22215
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Bug in { completion's comma removal
- Date: Fri, 10 Feb 2006 20:00:01 -0800
- In-reply-to: <237967ef0601061207h7802915dm580a12122a971242@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20060106180019.GB10111@xxxxxxxxxxxxx> <237967ef0601061207h7802915dm580a12122a971242@xxxxxxxxxxxxxx>
On Fri, Jan 06, 2006 at 09:07:19PM +0100, Mikael Magnusson wrote:
> While we're talking about {} [...] there's no way (that i've figured
> out) to escape a comma inside the braces.
I've looked at this, and I'm thinking that the easiest thing to do is to
sometimes mark a comma with ISPECIAL, just like {, }, space, etc. Since
user-typed commas inside a brace are already transformed into "Comma"
(0x97), this ensures that completing filenames that contain a comma get
a backslash prefixed, and that a user-typed "\," sequence does not lose
the backslash. I'll attach a patch that works, but I'd appreciate some
input if someone would care to take a look at what I've done.
Two caveats about my patch:
- When I turn on the ISPECIAL bit for ',', I also set a flag that makes
sure that all calls to inittyptab() continue to set ISPECIAL for the
comma. Without this, a comma's specialness was quickly lost.
- Expansion of { ... } sequences by the completion system are still not
working right if there are backslash-escaped commas and/or closing
braces. (The shell handles "echo {foo\,bar,foo\,baz,bar\}foo}"
properly, just not TAB expansion.)
..wayne..
--- Src/utils.c 6 Feb 2006 11:57:07 -0000 1.116
+++ Src/utils.c 11 Feb 2006 03:29:36 -0000
@@ -2515,6 +2515,8 @@ equalsplit(char *s, char **t)
return 0;
}
+static int specialcomma;
+
/* the ztypes table */
/**/
@@ -2614,10 +2614,22 @@ inittyptab(void)
}
for (s = SPECCHARS; *s; s++)
typtab[STOUC(*s)] |= ISPECIAL;
+ if (specialcomma)
+ typtab[STOUC(',')] |= ISPECIAL;
if (isset(BANGHIST) && bangchar && interact && isset(SHINSTDIN))
typtab[bangchar] |= ISPECIAL;
}
+/**/
+void
+makecommaspecial(int yesno)
+{
+ if ((specialcomma = yesno) != 0)
+ typtab[STOUC(',')] |= ISPECIAL;
+ else
+ typtab[STOUC(',')] &= ~ISPECIAL;
+}
+
/**/
#ifdef MULTIBYTE_SUPPORT
--- Src/Zle/zle_tricky.c 12 Jan 2006 00:51:53 -0000 1.64
+++ Src/Zle/zle_tricky.c 11 Feb 2006 03:29:38 -0000
@@ -586,6 +586,7 @@ docomplete(int lst)
}
active = 1;
comprecursive = 0;
+ makecommaspecial(0);
if (undoing)
setlastline();
@@ -662,6 +663,7 @@ docomplete(int lst)
unmetafy_line();
zsfree(s);
active = 0;
+ makecommaspecial(0);
return 1;
}
ocs = zlemetacs;
@@ -852,6 +854,7 @@ docomplete(int lst)
unmetafy_line();
active = 0;
+ makecommaspecial(0);
return dat[1];
}
@@ -1593,6 +1596,7 @@ get_comp_string(void)
p = tp - 1;
continue;
}
+ makecommaspecial(1);
if (bbeg) {
Brinfo new;
int len = bend - bbeg;
@@ -1639,6 +1643,7 @@ get_comp_string(void)
continue;
}
cant = 1;
+ makecommaspecial(1);
break;
}
if (p == curs) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author