From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19101 invoked by alias); 2 Apr 2016 18:17:30 -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: 38232 Received: (qmail 17815 invoked from network); 2 Apr 2016 18:17:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=1NDaoTIr5U5f357TI6FFkNBd8Y/eXRvGmAp7Xn0yprY=; b=D8It8JOe5gTa5IBgDiekhAY5FmD+j36GLDi8iaW9bgUq9HLy0ubL+PNR7RNEDvQ+OW zFRwiRD/qYrH+CbLOXO8onUN/wLAjspsaFr3aDUO8oP9HmFfLxuXP8YjSx9x9GzBh5aQ DWtinnox/eVGuXG0OGse6mxeyk+GJESyIwPRIEfEaRFudN4ZLZM3uIyJDrEevuxbVQc0 m4nUjdcDB3rbKLjhiwGJKsY9SkiqfLFdHyhGqTnyUVivdGQkU39KPdviBNNObJCNQM5H FPMGre5QXTyxJIhudFAz3+RD8Eeg/Mag8r0/opvJOhTl1H0TAr00bi8jdyRvxhLUNC9l /+6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=1NDaoTIr5U5f357TI6FFkNBd8Y/eXRvGmAp7Xn0yprY=; b=JB3m1xhH/i2+cOtbtDo9dCAHULWE8XMxG0uniWUbbBMV28EEjq/O3v+YCnfqZxzFUa eArAJIyTF9p7d5+PfjxFpG0Tlgq4g83/SDojucUBuj5kniAX9aKO1CbQ910yJBrP/J9M +K+n/kkjMKZIiD6HYp47U0WOcuf+1sjSgAGuXaQQrEfhp+6KEOMEmCAMCF5NWu2JSCwn jMc+aE55C9SAigrWHiIZ+6l58/xPrCU4QofLCdcTvDUohpRTwouAOjo+1SPzTI7OXffD /5vqUCJ/VARLCsO26KIvU492eDOfnCvtC6+DSJpnXJRafxF/hJOJbj6ZvpY8ZYwG9K7y +cxg== X-Gm-Message-State: AD7BkJJ7UXXdVSqsInawNPKFGaJ4vAkDB/N3vr0BrLbfICAFGxpv0nLkcXJfRoWdrFT44Q== X-Received: by 10.66.141.103 with SMTP id rn7mr40182615pab.70.1459621042768; Sat, 02 Apr 2016 11:17:22 -0700 (PDT) From: Bart Schaefer Message-Id: <160402111815.ZM1925@torch.brasslantern.com> Date: Sat, 2 Apr 2016 11:18:15 -0700 In-Reply-To: <160401232021.ZM25900@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: Completion in empty double-quotes generates error" (Apr 1, 11:20pm) References: <160330110652.ZM1432@torch.brasslantern.com> <20160401053633.GA17993@tarsus.local2> <160401181824.ZM23675@torch.brasslantern.com> <20160402032950.GA10638@tarsus.local2> <160401232021.ZM25900@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Completion in empty double-quotes generates error MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 1, 11:20pm, Bart Schaefer wrote: } Subject: Re: Completion in empty double-quotes generates error } } In the redirection 2>1, gotword() has concluded that the word to be } completed is "1" rather than (a prefix of) "2". } } This is probably because the lexer wants to treat "2>" as a single } token Indeed, zshlex() consumes "2>" as a single OUTANG token with tokfd = 2 handled as metadata. This means that in "2>1" the only complete-able "word" that the lexer recognizes on the line is the "1" following the redirection. What would one expect to be completed with the cursor on the "2"? The -redirect- special context is for what comes *after* the operator. I can think of only two choices: 1. Complete as if there were an implicit space to the right of the cursor. This makes some sense because "2>" is treated as the same single token as ">" all alone. 2. Treat it as an error and simply fail. Patch below does this, but it ought to also insert a space to the right of any inserted word, which I haven't done yet. If someone else knows how to do that, please jump in. As a bonus, this patch fixes a case where wordpos was incorrectly left at 1 near a redirection, causing command completion to incorrectly be invoked. diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index a89b2a3..553721c 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1238,6 +1238,15 @@ get_comp_string(void) /* Record if we haven't had the command word yet */ if (wordpos == redirpos) redirpos++; + if (zlemetacs < (zlemetall - inbufct)) { + /* Cursor is in the middle of a redirection, treat as a word */ + DPUTS3(addedx, + "added x in redirect: wb = %d, we = %d, zlemetacs = %d", + wb, we, zlemetacs); + wb = zlemetacs; + we = zlemetall - inbufct; + wordpos++; + } } if (tok == DINPAR) tokstr = NULL;