From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9305 invoked by alias); 26 Jun 2015 16:46:32 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35615 Received: (qmail 19595 invoked from network); 26 Jun 2015 16:46:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-a9-558d81e1a28d Date: Fri, 26 Jun 2015 17:46:22 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: typeset completion Message-id: <20150626174622.36f9523d@pwslap01u.europe.root.pri> In-reply-to: <20150625102923.1dc227ff@pwslap01u.europe.root.pri> References: <5578996E.3080700@thequod.de> <150610191427.ZM30841@torch.brasslantern.com> <5579C247.1060800@thequod.de> <150611183639.ZM32247@torch.brasslantern.com> <20150612094237.338f79d5@pwslap01u.europe.root.pri> <20150619123930.2688d9e3@pwslap01u.europe.root.pri> <7337.1434735386@thecus.kiddle.eu> <20150625102923.1dc227ff@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsVy+t/xy7oPG3tDDXrvKlkcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujK7NO9kKjklWXNmY08D4XqiLkZNDQsBE4vr796wQtpjEhXvr 2boYuTiEBJYySlzcdJ8JwpnBJNFwdBsrhLONUaL72X6wFhYBVYmNJxaxgNhsAoYSUzfNZuxi 5OAQEdCWaP8oBhIWFlCSmPPhExOIzStgL9F6bioLSAmngINE838WiJHvmCTOPNsONpJfQF/i 6l+Iegmg+plXzjBC9ApK/Jh8D2wVs4CWxOZtTawQtrzE5jVvmUFsIQF1iRt3d7NPYBSahaRl FpKWWUhaFjAyr2IUTS1NLihOSs810itOzC0uzUvXS87P3cQICdmvOxiXHrM6xCjAwajEwzuz tSdUiDWxrLgy9xCjBAezkgiveXlvqBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHembvehwgJpCeW pGanphakFsFkmTg4pRoYj0kXvmNbdnPxXfEr38x27WPniMz9Yrcx5Fpy3u3MtUVbP6x9fOxA 47LI4898l3z9Uep6IJCjZAnH+aWfjPIvz7Mv3y1l8LPlyadnK2wW3A3Smf+tlak32KFSsX6R +Jb7v2tvRvBySE1IuVbFrM8afuSIajpXbcHqAAOL3+q5Arfk+N9tdFrFo8RSnJFoqMVcVJwI ANrZ2zxVAgAA On Thu, 25 Jun 2015 10:29:23 +0100 Peter Stephenson 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: