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

Re: PATCH: completions for su and implicit fg/bg



Peter Stephenson wrote:

> > It's `compset -q' -- and with that I can repeat the question I asked
> > at the time when I sent the completion-quoting-patch: currently the
> > `-q' option only has an effect if the word on the command line is
> > quoted -- should we change it to work on unquoted strings, too?
> 
> Presumably the answer should be yes, for consistency.  I already gave an
> example with backslashing where it should be treated that way.

This allows `compset -q' on unquoted words -- almost. There is a
problem when the match contains characters that have to be quoted. In
such cases the match should be quoted twice (`a b' should be inserted
as `a\\\ b'), but currently the completion code is far from being
prepared for such double-quoting and I'm seeing to much places where
changes are needed for a quick patch.
I'll take care of that later.

Bye
 Sven

diff -u os/Zle/compctl.c Src/Zle/compctl.c
--- os/Zle/compctl.c	Fri Jul  9 10:56:31 1999
+++ Src/Zle/compctl.c	Fri Jul  9 15:41:02 1999
@@ -2096,9 +2096,7 @@
     case 'P': test = CVT_PREPAT; break;
     case 's': test = CVT_SUFNUM; break;
     case 'S': test = CVT_SUFPAT; break;
-    case 'q': return !(compquote && *compquote &&
-		       (*compquote == '\'' || *compquote == '"') &&
-		       !set_comp_sepptr());
+    case 'q': return set_comp_sepptr();
     default:
 	zerrnam(name, "bad option -%c", NULL, argv[0][1]);
 	return 1;
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Fri Jul  9 10:56:33 1999
+++ Src/Zle/zle_tricky.c	Fri Jul  9 15:18:10 1999
@@ -5171,10 +5171,16 @@
 	zsfree(compisuffix);
 	compisuffix = ztrdup("");
 	zsfree(compqiprefix);
-	compqiprefix = qp;
 	zsfree(compqisuffix);
-	compqisuffix = qs;
-
+	if (instring) {
+	    compqiprefix = qp;
+	    compqisuffix = qs;
+	} else {
+	    compqiprefix = ztrdup(quotename(qp, NULL));
+	    zsfree(qp);
+	    compqisuffix = ztrdup(quotename(qs, NULL));
+	    zsfree(qs);
+	}
 	freearray(compwords);
 	i = countlinknodes(foo);
 	compwords = (char **) zalloc((i + 1) * sizeof(char *));
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo	Fri Jul  9 10:56:41 1999
+++ Doc/Zsh/compwid.yo	Fri Jul  9 15:42:36 1999
@@ -620,7 +620,7 @@
 testing and modification is performed as if it were not given.
 )
 item(tt(-q))(
-If the cursor is currently inside single or double quotes, the word
+The word
 currently being completed is split in separate words at the spaces. The 
 resulting words are stored in the tt(words) array, and tt(PREFIX),
 tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to reflect the 

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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