From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9387 invoked by alias); 20 Mar 2015 01:02: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: 20029 Received: (qmail 25099 invoked from network); 20 Mar 2015 01:02: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.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=sqilS8wTVvp7JvxLJOWdeC5hXWu6wvU+Wb+QK4gDJOA=; b=QvXeenbE103dvqdXi/b84iTo3/gdUtEqYrYCCRFc4mFsJjRc305Nz+HEWPdG7Y/pXQ QjhZSi1GUt62NAB6mX7Q2KM3TV9bv/KyQJslR2U2kdP34VlS0yL9yCYO18CN4Jegu7Ni cOnVmK1d6/+NS9Y1BeXCEVwUcukl+l7D5gv/kb71Z9LJeE6Zcf1q6QwD3hsG+t9cLykh rDjLSoY2X1Nlviml+RakkJbN1rVn4klY3SLiYYNGth11d79ws2dBuGiUSluo6ve24D7X xrODqrRUrQ3rBvHxHsYF6uVSvCJ9g1zx4NvcTWLgb7l8tt/TDvx8UwWBsu/zSSsgCHFt oWwQ== X-Gm-Message-State: ALoCoQnV76tJT0IFDwaUkwdNr7h5tHA+4USs3p0FWvaDRr+7OvSMRpeYjThN5jN1GsrDm3w13Xos X-Received: by 10.202.213.214 with SMTP id m205mr6078349oig.52.1426813333995; Thu, 19 Mar 2015 18:02:13 -0700 (PDT) From: Bart Schaefer Message-Id: <150319180210.ZM8176@torch.brasslantern.com> Date: Thu, 19 Mar 2015 18:02:10 -0700 In-Reply-To: <150319090612.ZM18787@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: GLOB_COMPLETE and numbered directories" (Mar 19, 9:06am) References: <20150319073238.GN3548@tarsus.local2> <150319090612.ZM18787@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: GLOB_COMPLETE and numbered directories MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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?). 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