From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15347 invoked by alias); 20 Mar 2015 16:41:51 -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: 20034 Received: (qmail 5433 invoked from network); 20 Mar 2015 16:41:38 -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=tb+OuynyouidEZ6H6C+IlqFJ8hDkk+zCuU9Q79yQv74=; b=S4cZ+LIKCefo018c1T2c8r6BK3t58U8wpTAWDewn7Z6rMYMHZewJk0fJqfgMe8I/dk K1c1fsMNWy6m5x/pDScfpwXXRv2lvjZ+d5Y8JyZHpSGo9yc5QAc75MXI+yhd2AMucbg7 tj3dhFuj3VRNZ19812nOu9Fy4JeP7vHHG70EpFik2cn6vMYDaAa+Gsj9JMVatXyO5dYf h3HuSvBVpY1CnI8wNSxGCfC1IhFz759SPbBNL0FRLBjHd7uyZoVdBL+cw4gZCfvYJko3 P1NylwmdsoWIhwi3MO6e+ibswqKaqMyWfzDCxZGkIejnLHyMvIUjdTyzaKApAffCsE19 goxA== X-Gm-Message-State: ALoCoQnoFHfekO40c/pbFHGUUnkg9/5q5DivWWcbUGDa0LyhvGONYuJ319emMZfVY4QhReLSUV1T X-Received: by 10.182.241.197 with SMTP id wk5mr8564454obc.0.1426869697058; Fri, 20 Mar 2015 09:41:37 -0700 (PDT) From: Bart Schaefer Message-Id: <150320094134.ZM21989@torch.brasslantern.com> Date: Fri, 20 Mar 2015 09:41:34 -0700 In-Reply-To: <20150320042512.GD5478@tarsus.local2> Comments: In reply to Daniel Shahaf "Re: GLOB_COMPLETE and numbered directories" (Mar 20, 4:25am) References: <20150319073238.GN3548@tarsus.local2> <150319090612.ZM18787@torch.brasslantern.com> <150319180210.ZM8176@torch.brasslantern.com> <20150320042512.GD5478@tarsus.local2> 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 20, 4:25am, Daniel Shahaf wrote: } } Bart Schaefer wrote on Thu, Mar 19, 2015 at 18:02:10 -0700: } > 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. Upon consideration, I wonder if the following might not be preferable. I think the behavior described above remains unchanged. I'm still puzzled as to why the internals don't do this correctly; the cursor is obviously at the expected position. diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index d6a1007..977ab49 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -68,6 +68,16 @@ 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]" + SUFFIX="$PREFIX[upos,-1]$SUFFIX" + PREFIX="$PREFIX[1,upos-1]" +fi + # Special completion contexts after `~' and `='. if [[ -z "$compstate[quote]" ]]; then