From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20277 invoked by alias); 10 Nov 2013 20:25:37 -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: 18137 Received: (qmail 15996 invoked from network); 10 Nov 2013 20:25:31 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <131110122530.ZM21629@torch.brasslantern.com> Date: Sun, 10 Nov 2013 12:25:30 -0800 In-reply-to: Comments: In reply to Thomas Ballinger "Re: custom script Bash completion" (Nov 10, 2:09pm) References: <131110102458.ZM21475@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users Subject: Re: custom script Bash completion MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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