From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5662 invoked by alias); 3 Apr 2015 16:51:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20077 Received: (qmail 12444 invoked from network); 3 Apr 2015 16:51:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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:content-type; bh=0P51bKDZ5o8OxNpJdGaBMmd6rT8dP0PHlauHi0xQfqE=; b=GYGmdXwAnhNOuNEb+6LVqPOn3PR9UVZTfYUomfOQnozpXyRV16CRbpMG4QLUr27Wpz G6+potbwrq4taDzesor5YZ7g9TyofRzQsBF4rm28PGFWmnOIoLyIiwmbQv8AhUR2FAJ0 Yt6t0Pvh5leKnqfP3+Uin3j+jzvWWG1UZk8GRE7MmYHln9UIwNC2lCDgOLdv9hGaZTgt 4glAFSNuyjD8lajuFhydQyuc/lOQk41737/+qCznyLDMBMnZEI9X62t56M0clYnwuydz Odf+Q2OyVGZV1ZoIizbqxhS2TW2VZRbhKPUyVnUZc2f43ZZ4isqZSlCCxlHf6xl1Qfj/ BNlQ== X-Gm-Message-State: ALoCoQl5viUXWyGCxYeyHlFg92LghGvrQUhuIVaST2jRYaUkcqRhS5vrvnSnAmQF2mEMp/z2zmLe X-Received: by 10.60.132.33 with SMTP id or1mr4041051oeb.82.1428079885267; Fri, 03 Apr 2015 09:51:25 -0700 (PDT) From: Bart Schaefer Message-Id: <150403095122.ZM13703@torch.brasslantern.com> Date: Fri, 3 Apr 2015 09:51:22 -0700 In-Reply-To: <20150403061621.GF2805@localhost.localdomain> Comments: In reply to Han Pingtian "_history_complete_word and history word begin with quote" (Apr 3, 2:16pm) References: <20150403061621.GF2805@localhost.localdomain> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-user Subject: Re: _history_complete_word and history word begin with quote MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 3, 2:16pm, Han Pingtian wrote: } } Looks like if a history word begins with quote, _history_complete_word } cannot complete it? This is a more generic issue which just happens to be more easily seen with _history_complete_word. The gist of it is that, if the word has an quote mark to the left of the cursor, then completion does not treat the quote as part of the word to be matched, but instead tries to append new text to the quoted string. This applies everywhere, not just for history words; e.g. if you type an open quote and then press TAB to complete file names, those names will appear after the opening quote and a closing quote will be offered if the file is not a directory. This is meant to allow the user to choose how a file name that contains spaces or metacharacters will be quoted in the final command line, rather than forcing a quoting style. (It would be a whole lot easier for the internals if we forced the quoting, and completion did that at first years ago, but too many users griped.) There is presently no way to turn this off or otherwise force the quote to become part of the match target. $compstate[quote] is read-only. The closest we could get is to run "compset -q" when then produces completions like this: torch% echo "\"foo bar\" world hello print \"foo bar\" print Or without the quote on the command line: torch% echo world hello print \"foo\ bar\" print We could instead peel the quotes off the history words before offering them as completions (diff below) but this might have unwanted side- effects elsewhere. diff --git a/Completion/Base/Completer/_history b/Completion/Base/Completer/_history index 63878ac..cd69ca1 100644 --- a/Completion/Base/Completer/_history +++ b/Completion/Base/Completer/_history @@ -51,9 +51,14 @@ ISUFFIX= # We skip the first element of historywords so the current word doesn't # interfere with the completion +local -a hslice while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do + if [[ -n $compstate[quote] ]] + then hslice=( ${(Q)historywords[beg,beg+slice]} ) + else hslice=( ${historywords[beg,beg+slice]} ) + fi _wanted "$opt" history-words expl 'history word' \ - compadd -Q -a 'historywords[beg,beg+slice]' + compadd -Q -a hslice (( beg+=slice )) done