zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: zsh-workers@sunsite.dk
Subject: Re: Bug in { completion's comma removal
Date: Fri, 10 Feb 2006 20:00:01 -0800	[thread overview]
Message-ID: <20060211040001.GG14115@dot.blorf.net> (raw)
In-Reply-To: <237967ef0601061207h7802915dm580a12122a971242@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]

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..

[-- Attachment #2: comma.patch --]
[-- Type: text/plain, Size: 1582 bytes --]

--- 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) {

  parent reply	other threads:[~2006-02-11  4:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-06 18:00 Wayne Davison
2006-01-06 20:07 ` Mikael Magnusson
2006-01-06 20:36   ` Wayne Davison
2006-01-07  4:50     ` Mikael Magnusson
2006-02-11  4:00   ` Wayne Davison [this message]
2006-02-13 10:51     ` Peter Stephenson
2006-02-09 22:17 ` Wayne Davison

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=20060211040001.GG14115@dot.blorf.net \
    --to=wayned@users.sourceforge.net \
    --cc=zsh-workers@sunsite.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).