From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: PATCH: typeset completion
Date: Fri, 26 Jun 2015 17:46:22 +0100 [thread overview]
Message-ID: <20150626174622.36f9523d@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20150625102923.1dc227ff@pwslap01u.europe.root.pri>
On Thu, 25 Jun 2015 10:29:23 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> > This is perhaps jumping ahead a bit but for completion, it seems we now
> > get -command- context after typeset. As long as -var- context is applied
> > inside the actual contexts, having -command- context otherwise for
> > typeset would probably work fine.
>
> That still needs looking at --- as this is a rather grungy interface
> into the main shell it's a bit of a dark art whether this should be
> tweaked by fixing up the context or fixing up the handler, or whether
> it's one of the cases where the Red Death holds illimitable sway and
> dominion. With any luck one of the first two is possible.
>
> Scalar and array contexts after typeset assignment seem to be working OK
> as a -value-.
I believe this fixes the major issues within the main completion code,
but just in the nick of time before the Red Death leapt out of it...
pws
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index f18ad17..7217abc 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1190,6 +1190,12 @@ get_comp_string(void)
/* Get the next token. */
if (linarr)
incmdpos = 0;
+ /*
+ * Arrange to parse assignments after typeset etc...
+ * but not if we're already in an array.
+ */
+ if (cmdtok == TYPESET)
+ intypeset = !linarr;
ctxtlex();
if (tok == LEXERR) {
@@ -1272,10 +1278,11 @@ get_comp_string(void)
tt0 = NULLTOK;
}
if (lincmd && (tok == STRING || tok == FOR || tok == FOREACH ||
- tok == SELECT || tok == REPEAT || tok == CASE)) {
+ tok == SELECT || tok == REPEAT || tok == CASE ||
+ tok == TYPESET)) {
/* The lexer says, this token is in command position, so *
* store the token string (to find the right compctl). */
- ins = (tok == REPEAT ? 2 : (tok != STRING));
+ ins = (tok == REPEAT ? 2 : (tok != STRING && tok != TYPESET));
zsfree(cmdstr);
cmdstr = ztrdup(tokstr);
cmdtok = tok;
@@ -1290,7 +1297,7 @@ get_comp_string(void)
* handle completing multiple SEPER-ated command positions on
* the same command line, e.g., pipelines.
*/
- ins = (cmdtok != STRING);
+ ins = (cmdtok != STRING && cmdtok != TYPESET);
}
if (!lexflags && tt0 == NULLTOK) {
/* This is done when the lexer reached the word the cursor is on. */
@@ -1436,7 +1443,7 @@ get_comp_string(void)
we = wb = zlemetacs;
clwpos = clwnum;
t0 = STRING;
- } else if (t0 == STRING) {
+ } else if (t0 == STRING || t0 == TYPESET) {
/* We found a simple string. */
s = ztrdup(clwords[clwpos]);
} else if (t0 == ENVSTRING) {
@@ -1492,7 +1499,7 @@ get_comp_string(void)
zlemetaline = tmp;
zlemetall = strlen(zlemetaline);
}
- if (t0 != STRING && inwhat != IN_MATH) {
+ if (t0 != STRING && t0 != TYPESET && inwhat != IN_MATH) {
if (tmp) {
tmp = NULL;
linptr = zlemetaline;
diff --git a/Src/lex.c b/Src/lex.c
index d56f670..baeed13 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -339,6 +339,7 @@ ctxtlex(void)
incmdpos = 1;
break;
case STRING:
+ case TYPESET:
/* case ENVSTRING: */
case ENVARRAY:
case OUTPAR:
next prev parent reply other threads:[~2015-06-26 16:46 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5578996E.3080700@thequod.de>
[not found] ` <150610191427.ZM30841@torch.brasslantern.com>
[not found] ` <5579C247.1060800@thequod.de>
[not found] ` <150611183639.ZM32247@torch.brasslantern.com>
[not found] ` <20150612094237.338f79d5@pwslap01u.europe.root.pri>
2015-06-19 11:39 ` Typeset with array Peter Stephenson
2015-06-19 14:06 ` Peter Stephenson
2015-06-19 18:54 ` Bart Schaefer
2015-06-19 20:16 ` Peter Stephenson
2015-06-19 21:11 ` Eric Cook
2015-06-19 16:09 ` Bart Schaefer
2015-06-19 20:32 ` Peter Stephenson
2015-06-20 3:50 ` Bart Schaefer
2015-06-20 17:05 ` Peter Stephenson
2015-06-19 17:36 ` Oliver Kiddle
2015-06-19 18:40 ` Bart Schaefer
2015-06-25 9:29 ` Peter Stephenson
2015-06-25 15:16 ` Bart Schaefer
2015-06-25 15:39 ` Peter Stephenson
2015-06-25 16:08 ` Bart Schaefer
2015-06-25 16:34 ` Peter Stephenson
2015-06-26 13:51 ` PATCH: array slice Peter Stephenson
2015-06-26 23:07 ` Bart Schaefer
2015-06-27 19:42 ` Peter Stephenson
2015-06-27 20:09 ` Bart Schaefer
2015-06-26 16:46 ` Peter Stephenson [this message]
2015-06-26 19:14 ` Typeset with array Oliver Kiddle
2015-06-27 16:33 ` Peter Stephenson
2015-06-21 20:05 ` Peter Stephenson
2015-06-21 20:38 ` Peter Stephenson
2015-06-23 16:47 ` Peter Stephenson
2015-06-23 17:52 ` Mikael Magnusson
2015-06-23 20:17 ` Bart Schaefer
2015-06-23 20:21 ` Peter Stephenson
2015-06-23 20:24 ` Mikael Magnusson
2015-06-24 1:35 ` typeset -p with assoc array (was Re: Typeset with array) Bart Schaefer
2015-06-24 6:03 ` Bart Schaefer
2015-06-23 20:25 ` Typeset with array Bart Schaefer
2015-06-24 9:14 ` Peter Stephenson
2015-06-24 9:29 ` Peter Stephenson
2015-06-24 10:35 ` Roman Neuhauser
2015-06-24 13:00 ` Mikael Magnusson
2015-06-24 13:20 ` Peter Stephenson
2015-06-24 15:03 ` Bart Schaefer
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=20150626174622.36f9523d@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/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).