From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24175 invoked by alias); 29 Feb 2012 18:22:31 -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: 16816 Received: (qmail 29842 invoked from network); 29 Feb 2012 18:22:30 -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 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120229102216.ZM27937@torch.brasslantern.com> Date: Wed, 29 Feb 2012 10:22:16 -0800 In-reply-to: <4F4B58FE.3070008@googlemail.com> Comments: In reply to Martin Richter "context for globbing qualifiers based on command" (Feb 27, 11:20am) References: <4F4B58FE.3070008@googlemail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: context for globbing qualifiers based on command MIME-version: 1.0 Content-type: text/plain; charset=us-ascii (It wasn't necessary to send this inquiry twice. It sometimes takes a little while for a response.) On Feb 27, 11:20am, Martin Richter wrote: > > Is it possible to tweak the completion such that shell functions are > grouped at the top when pressing TAB when using (:e...) on a given command? > print -l *(e:TAB --> gives a lot of possible functions etc > but > special_command *(e:TAB > gives only shell function matching some regexp or gives only the single > function 'foo' or members of an array of functions? Unfortunately, no. The zstyle context after *(e: is identical to the context in any other command position. However, the $words array hasn't been altered, so you could write a function to be installed in your "completer" style that examines the values of $words[1] and $words[CURRENT], something like this: _special_command_glob_completer() { if [[ CURRENT -gt 1 && "$words[1]" = 'special_command' && "$words[CURRENT]" = *\(*e:* ]] then compset -p ${#words[CURRENT]} compadd -J special-globbers sum_equals product_equals return 0 else return 1 fi } zstyle ':completion:*' completer _expand \ _special_command_glob_completer \ _complete _match _ignored _approximate _prefix (the rest of that completer style is just for example, but you probably want at least _complete in there after your special one). It might also be possible to do this more generically with a "matcher" zstyle in the context :completion::complete:-command-::* but I'll leave that for someone else to work out. (It'd have to use "zstyle -e" and some kind of test similar to the "if" above.)