From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29327 invoked by alias); 29 Feb 2012 18:40:12 -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: 16819 Received: (qmail 10648 invoked from network); 29 Feb 2012 18:40:10 -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.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.50 as permitted sender) Received-SPF: pass (google.com: domain of mikachu@gmail.com designates 10.224.173.72 as permitted sender) client-ip=10.224.173.72; Authentication-Results: mr.google.com; spf=pass (google.com: domain of mikachu@gmail.com designates 10.224.173.72 as permitted sender) smtp.mail=mikachu@gmail.com; dkim=pass header.i=mikachu@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vJXTmGfzLr2V6/L0fpmeQ4JecM5y+aathqaauJQQU9c=; b=q98XQztm1U7vIQ8pET3hhNsQFM71FfS7+Ody14bkTogOO8Niqq0UqyEdFsf0oF9DqV d8TupYDI3rO/KxoN6nFpYMMAIupn8KGA3vy/tDCFHHTYUTTmaHzvW+uDoFFdt5Rmi0q5 15Vb2ASqqWcijbBpOVEJXcG3nU/tky1/z6yik= MIME-Version: 1.0 In-Reply-To: References: <4F4B58FE.3070008@googlemail.com> <120229102216.ZM27937@torch.brasslantern.com> Date: Wed, 29 Feb 2012 19:33:57 +0100 Message-ID: Subject: Re: context for globbing qualifiers based on command From: Mikael Magnusson To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 29 February 2012 19:32, Mikael Magnusson wrote: > On 29 February 2012 19:22, Bart Schaefer wrote: >> (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.) > > You can probably do this a bit less fragilely with $zsh_eval_context: > > % print -l $(echo .(e:'reply=($zsh_eval_context)':)) > cmdsubst > globqual > toplevel Ignore that :). -- Mikael Magnusson