From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22255 invoked by alias); 6 Dec 2010 14:54:26 -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: 15614 Received: (qmail 23131 invoked from network); 6 Dec 2010 14:54:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=5UaF2WFzfNNSz5vaJ36KT2IdrX14ud5HiI8u2v/C4SI=; b=rHl4QBDYB7z+JnNk1pXxPLQXnogVt1hnBsJA5YgwZm5jAE4opPUMKVfO7FuzulKqYo jrnzWX5v258tUFgqUXStZDKZYpXYhokKRBIhP6YvPNGx4I6hQ/vrxKsWSatIolGxIHTn siRab1WvEXLtKmx/qG5VzC8wES8Hh3yLEMe6A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=EpksyrL4fCVMlHZ0sq9c01nwefK0cFOMTKVa7HqTbcj2c38iGb1JVMO2yKtXqbPwe9 un74v/afC8fJyQBdHCPxsOHvkH8eJrvW5EHcvd8FBEyJdV3O3k/F8E07Twcci9lOWF6a O7iHdzGoPWILhE4DOjTJJG72l08nRvecPvb5A= MIME-Version: 1.0 In-Reply-To: <201012061512.21791.mrichter@theory.phy.tu-dresden.de> References: <201012061512.21791.mrichter@theory.phy.tu-dresden.de> Date: Mon, 6 Dec 2010 15:54:20 +0100 Message-ID: Subject: Re: Using the same completion function for various commands From: Mikael Magnusson To: mrichter@theory.phy.tu-dresden.de Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6 December 2010 15:12, Martin Richter wrote: > Hello, > > I'm searching the documentation for quite a while now but can't figure ou= t how > to do the following: > > I wrote a completion function which resides somewhere in $fpath, let's ca= ll it > _foo. But I don't want to have it applied on the command foo only. I want= to use > it on all commands matching a certain pattern, e.g. foo_1, foo_2, ... (or= foo_* > for short). Is it possible to define a context for this (like > :completion::complete:foo_*::) and use zstyle to bind this completer to i= t? > Unfortunately I couldn't figure out how. > =C2=A0zstyle "*" completer _ > only tells me about some built-ins. > > Thank you very much and please forgive me in case I oversaw something obv= ious in > the documentation. #compdef names... [ -[pP] patterns... [ -N names... ] ] The file will be made autoloadable and the function defined in it will be called when completing names, each of which is either the name of a [...] If the #compdef line contains one of the options -p or -P, the words following are taken to be patterns. The function will be called when completion is attempted for a command or context that matches one of the patterns. The options -p and -P are used to specify patterns to You can also do this in your .zshrc instead of in the completer if you wish, just write compdef _foo -p 'foo_*' At least that's what the documentation says, it doesn't seem to work that w= ell. --=20 Mikael Magnusson