From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24144 invoked by alias); 20 Mar 2015 04:25:17 -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: 20033 Received: (qmail 2382 invoked from network); 20 Mar 2015 04:25:16 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type:in-reply-to; s= mesmtp; bh=GD3wifjt4+kPLKxZiOPqTnM632E=; b=EzK3KZMy/AJUayv93yZUv ZwINuJXxMe73jKlg+aS5WavzYf2c64F19dfKpwpAMF3cTch7me54T9kupO9WidNO +OwdouDGiod3cVvFO8DH6vhknirS+wcEVT4cGNVOAjKNuMzRTld17R185IpjPZUX N/E7KMB/+CAU4P3tTktRm8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type:in-reply-to; s= smtpout; bh=GD3wifjt4+kPLKxZiOPqTnM632E=; b=pe4HHcUce087AxQ0M8K5 nWQwBuXlwbkT0MU2EdUABq/aYpgb0UVEohvq2/hQm1LnXedDECnnIPPtxG6bLcqy Wyc4Kt+kxgpeQEIjAxKEUfpMud7vM1A7ggTeJgmYnFyQtJZJw6CLpuSLodDufnr5 FgeZkpHhuBeNc+2g3Mix1Fo= X-Sasl-enc: 6WLuyYcG80Xf94tiCVB2U+Lm7gaFZLZDjL9F1UHJhrMI 1426825515 Date: Fri, 20 Mar 2015 04:25:12 +0000 From: Daniel Shahaf To: Bart Schaefer Cc: zsh-users@zsh.org Subject: Re: GLOB_COMPLETE and numbered directories Message-ID: <20150320042512.GD5478@tarsus.local2> References: <20150319073238.GN3548@tarsus.local2> <150319090612.ZM18787@torch.brasslantern.com> <150319180210.ZM8176@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <150319180210.ZM8176@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) Bart Schaefer wrote on Thu, Mar 19, 2015 at 18:02:10 -0700: > On Mar 19, 9:06am, Bart Schaefer wrote: > } > } It's supposed to be sufficient to "setopt completeinword" to get the > } behavior you want, and indeed it works if I literally type out > } > } % cat 1a/iota > } > } and then move the cursor to 1a/iota before pressing TAB. However, > } for some reason this doesn't happen when "continuing an in-progress > } completion" with a second TAB. I believe that's because the second > } tab just regenerates the listing with the same pattern as on the > } first tab, and that's not sufficient to disambiguate. > > So ... in the case of moving the cursor to after the "1" and pressing > TAB, $PREFIX = "1". But in the case of pressing the second TAB after > completing to "1a/iota", $PREFIX = "1a/iota" even though the cursor > is not at the end of the word. > > The fix is therefore something like this, though I don't know if I have > handled completeinword correctly (as in, I think this generates matches > on a second TAB even when completeinword is not set, but I don't think > anyone would object to that?). > 'cat 1a/iota' behaves (with the patch) as follows: - If this is the first tab and completeinword set: completes - If this is the first tab and completeinword unset: doesn't complete - If this is the second tab: completes I think that's fine because, in the 'this is the second tab and completeinword is unset' case, the _first_ tab was at the 'cat 1/i' case, so logically the overall completion that's happening here _is_ "completion at end of word", not in middle of word. Thanks, Daniel > diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete > index d6a1007..a89bc84 100644 > --- a/Completion/Base/Core/_main_complete > +++ b/Completion/Base/Core/_main_complete > @@ -68,6 +68,15 @@ if [[ "$compstate[insert]" = tab* ]]; then > compstate[insert]="${compstate[insert]//tab /}" > fi > > +# Second attempt at GLOB_COMPLETE > + > +if [[ "$compstate[pattern_match]" = "*" && > + "$_lastcomp[unambiguous]" = "$PREFIX" && > + -n "$_lastcomp[unambiguous_cursor]" ]]; then > + integer upos="$_lastcomp[unambiguous_cursor]" > + PREFIX="$PREFIX[1,upos-1]*$PREFIX[upos,-1]" > +fi > + > # Special completion contexts after `~' and `='. > > if [[ -z "$compstate[quote]" ]]; then