From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18638 invoked by alias); 10 Nov 2013 21:34:53 -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: 18138 Received: (qmail 11788 invoked from network); 10 Nov 2013 21:34:49 -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,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=XYaDOdukqYpkD9Vy0CRP9kRpYc+pB0YkmClCruXX7DA=; b=NRf2IrfqcVPt5kHODpcOJnDzE03Ij9D2sQ4sf25jMqMxCsnjPD7sAN0lnpMumLnQf+ 4U+L/YEiq64OCxB9f7g1lEgpnRBZAD7jZfg2LLBbP8XDM++wcjJtYp0QjbvnDDcx2xoy PWtGN57Ai2imYaJL7mxh4nTxAOHYDKB/FuJKeBqPJmAMRPymyHWEj/MqP7fHOuyuDDds gBQAaygmEXt8GL5F9eST9cUCbfxa/Cwrg4ruNV7OW6rRs1tuSY6DqXzB03FRqDJaoCQu 2ZrCiPOFuaY9kFsC9jdrrdPfX3npvRU0rHFNMCUlVJK66kHlTYOnsXSOCH2336i0xfy0 Kfxg== X-Received: by 10.152.23.137 with SMTP id m9mr19986235laf.17.1384119284129; Sun, 10 Nov 2013 13:34:44 -0800 (PST) MIME-Version: 1.0 Sender: thomasballinger@gmail.com In-Reply-To: <131110122530.ZM21629@torch.brasslantern.com> References: <131110102458.ZM21475@torch.brasslantern.com> <131110122530.ZM21629@torch.brasslantern.com> From: Thomas Ballinger Date: Sun, 10 Nov 2013 16:34:24 -0500 X-Google-Sender-Auth: _MFt7KjVTtrehr4x8ABuNQqT4EE Message-ID: Subject: Re: custom script Bash completion To: Bart Schaefer Cc: zsh-users Content-Type: multipart/alternative; boundary=089e0160a67641e5fc04ead96222 --089e0160a67641e5fc04ead96222 Content-Type: text/plain; charset=ISO-8859-1 Thanks very much Bart. I regret I can't be this volunteer at this time, but best of luck if anyone takes it on. One of these days I'll learn to write a real zsh completion script and use that instead :) Tom On Sun, Nov 10, 2013 at 3:25 PM, Bart Schaefer wrote: > On Nov 10, 2:09pm, Thomas Ballinger wrote: > } > } [...] completion suggestions are still filtered though by "values > } that the user has typed the first letters of," preventing the fuzzy > } completion I'd written from taking effect: > > Zsh completion assumes that the completion function is going to produce > all possible words that could appear at that position on the command > line; the internals then perform the filtering to match against the > partial word that is already present if any. It was our feeling at the > time that it was far too much to expect every completion function author > to consider details such as whether the cursor was in the middle of the > word, etc. The "compadd -U" option was created to enable authors to > have that degree of control, but it's not the default and it's not used > in the emulation functions defined by bashcompinit. > > } I imagine I need to turn off some zsh completion feature for > } this completion? > > I think you're going to have to replace bashcompinit with a slightly > edited version. Perhaps if we get a volunteer to update bashcompinit, > that person can figure out how to make this optional. In any case, > according to comments in bashcompinit the diff below might be what you > need. > > I threw in making "complete -C" pass the same args as "complete -F". > > diff --git a/Completion/bashcompinit b/Completion/bashcompinit > index 902fa88..e2b3597 100644 > --- a/Completion/bashcompinit > +++ b/Completion/bashcompinit > @@ -26,7 +26,7 @@ _bash_complete() { > compset -S '/*' && matches=( ${matches%%/*} ) > compadd -Q -f "${suf[@]}" -a matches && ret=0 > else > - compadd -Q "${suf[@]}" -a matches && ret=0 > + compadd -U -Q "${suf[@]}" -a matches && ret=0 > fi > fi > > @@ -137,7 +137,10 @@ compgen() { > unsetopt nullglob > ;; > W) results+=( ${(Q)~=OPTARG} ) ;; > - C) results+=( $(eval $OPTARG) ) ;; > + C) > + local -a args > + args=( "${words[0]}" "${@[-1]}" "${words[CURRENT-2]}" ) > + results+=( $(eval $OPTARG "${args[@]}") ) ;; > P) prefix="$OPTARG" ;; > S) suffix="$OPTARG" ;; > X) > @@ -152,7 +155,7 @@ compgen() { > > # support for the last, `word' option to compgen. Zsh's matching does a > # better job but if you need to, comment this in and use compadd -U > - # (( $# >= OPTIND)) && results=( "${(M)results[@]:#${@[-1]}*}" ) > + (( $# >= OPTIND)) && results=( "${(M)results[@]:#${@[-1]}*}" ) > > print -l -r -- "$prefix${^results[@]}$suffix" > } > > -- > Barton E. Schaefer > --089e0160a67641e5fc04ead96222--