From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: completion after ${"${foo
Date: Mon, 14 Jun 1999 10:30:41 +0200 (MET DST) [thread overview]
Message-ID: <199906140830.KAA30250@beta.informatik.hu-berlin.de> (raw)
... failed because the completion code removed the quote. I've fixed
this by not removing the quotes at all when completing only in a
parameter expansion and by not quoting the surrounding strings when
re-inserting them into the line. This has one problem: completion
after foo\ bar${foo<TAB> removes the backslash (completion after
"foo bar${foo<TAB> works, however). I currently see no way around this
-- until we make the lexer return different tokens for quotes inside
parameter expansions.
The patch also fixes _brace_parameter so that it doesn't leave the
command line in a state that is certainly wrong (which could happen
with completeinword set and completing ${"foo" with the cursor on the
second quote).
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Mon Jun 14 09:16:29 1999
+++ Src/Zle/zle_tricky.c Mon Jun 14 10:20:57 1999
@@ -681,12 +681,11 @@
/* Check if we have to complete a parameter name. */
static char *
-check_param(char *s, int set, char **ep)
+check_param(char *s, int set, int test)
{
char *p;
- int bq = 0, eq = 0, i;
- if (!ep)
+ if (!test)
ispar = parq = eparq = 0;
/* Try to find a `$'. */
for (p = s + offs; p > s && *p != String && *p != Qstring; p--);
@@ -726,9 +725,9 @@
e = b;
if (br) {
- while (*e == (ep ? Dnull : '"'))
- e++, parq++, bq++;
- if (!ep)
+ while (*e == (test ? Dnull : '"'))
+ e++, parq++;
+ if (!test)
b = e;
}
/* Find the end of the name. */
@@ -749,14 +748,12 @@
if (offs <= e - s && offs >= b - s && n <= 0) {
if (br) {
p = e;
- while (*p == (ep ? Dnull : '"'))
- p++, parq--, eparq++, eq++;
+ while (*p == (test ? Dnull : '"'))
+ p++, parq--, eparq++;
}
/* It is. */
- if (ep) {
- *ep = e;
+ if (test)
return b;
- }
/* If we were called from makecomplistflags(), we have to set the
* global variables. */
@@ -765,21 +762,12 @@
mflags |= CMF_PARBR;
/* Get the prefix (anything up to the character before the name). */
- for (i = eq, p = e; i; i--, p++)
- *p = '.';
- isuf = quotename(e, NULL);
- for (i = eq, p = isuf; i; i--, p++)
- *p = '"';
+ isuf = dupstring(e);
+ untokenize(isuf);
*e = '\0';
ripre = dupstring(s);
ripre[b - s] = '\0';
- for (i = bq, p = ripre + (b - s) - 1; i; i--, p--)
- *p = '.';
- ipre = quotename(ripre, NULL);
- for (i = bq, p = ripre + strlen(ripre) - 1; i; i--, p--)
- *p = '"';
- for (i = bq, p = ipre + strlen(ipre) - 1; i; i--, p--)
- *p = '"';
+ ipre = dupstring(ripre);
untokenize(ipre);
}
else
@@ -1534,11 +1522,12 @@
/* This variable will hold the current word in quoted form. */
qword = ztrdup(s);
offs = cs - wb;
- if ((p = check_param(s, 0, &tt))) {
- for (; *p == Dnull; p++)
- *p = '"';
- for (; *tt == Dnull; tt++)
- *tt = '"';
+ if ((p = check_param(s, 0, 1))) {
+ for (p = s; *p; p++)
+ if (*p == Dnull)
+ *p = '"';
+ else if (*p == Snull)
+ *p = '\'';
}
if (*s == Snull || *s == Dnull) {
char *q = (*s == Snull ? "'" : "\""), *n = tricat(qipre, q, "");
@@ -4985,11 +4974,21 @@
ll = oll;
if (cur < 0 || i < 1)
return 1;
+ owb = offs;
+ offs = soffs;
+ if ((p = check_param(ns, 0, 1))) {
+ for (p = ns; *p; p++)
+ if (*p == Dnull)
+ *p = '"';
+ else if (*p == Snull)
+ *p = '\'';
+ }
+ offs = owb;
if (*ns == Snull || *ns == Dnull) {
instring = (*ns == Snull ? 1 : 2);
inbackt = 0;
swb++;
- if (ns[strlen(ns) - 1] == *ns)
+ if (ns[strlen(ns) - 1] == *ns && ns[1])
swe--;
autoq = (*ns == Snull ? '\'' : '"');
} else {
diff -u oc/Base/_brace_parameter Completion/Base/_brace_parameter
--- oc/Base/_brace_parameter Mon Jun 14 09:20:07 1999
+++ Completion/Base/_brace_parameter Mon Jun 14 09:26:00 1999
@@ -16,4 +16,6 @@
n=${(M)#ls##\"#}
q=${(M)lp%%\"#}
+[[ n -gt 0 ]] && suf=''
+
_parameters -s "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/'
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~1999-06-14 8:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=199906140830.KAA30250@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).