From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12690 invoked from network); 5 Dec 2003 14:23:31 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 5 Dec 2003 14:23:31 -0000 Received: (qmail 15784 invoked by alias); 5 Dec 2003 14:23:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6844 Received: (qmail 15747 invoked from network); 5 Dec 2003 14:23:10 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 5 Dec 2003 14:23:10 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [193.109.254.211] by sunsite.dk (MessageWall 1.0.8) with SMTP; 5 Dec 2003 14:23:10 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-7.tower-36.messagelabs.com!1070634188!2281160 X-StarScan-Version: 5.1.13; banners=-,-,- Received: (qmail 30733 invoked from network); 5 Dec 2003 14:23:08 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-7.tower-36.messagelabs.com with SMTP; 5 Dec 2003 14:23:08 -0000 Received: from gmcs3.local ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id hB5EN8uB025249; Fri, 5 Dec 2003 14:23:08 GMT Received: from gmcs3.local (localhost [127.0.0.1]) by gmcs3.local (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id hB5ER5216500; Fri, 5 Dec 2003 15:27:05 +0100 cc: zsh-users@sunsite.dk X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <9hp0tv0i0066fbbh857hklmcs43v78u67d@4ax.com> From: Oliver Kiddle References: <4222.1070552274@csr.com> <2542.1070621678@gmcs3.local> <9hp0tv0i0066fbbh857hklmcs43v78u67d@4ax.com> To: zzapper Subject: Re: Why doesn't cd ignore files when you type say "cd fred*" Date: Fri, 05 Dec 2003 15:27:05 +0100 Message-ID: <16498.1070634425@gmcs3.local> zzapper wrote: > > > >bindkey '\e*' match-word > >zstyle ':completion:match-word::::' completer _all_matches _match _ignored > >zstyle ':completion:match-word:*' match-original both > >zle -C match-word complete-word _generic > > Oliver that works great but what is all that gobbledegook? It's not easy to explain that fully in a short e-mail. Hopefully you're already familar with bindkey. It allows you to bind a key or key combination to an editor command. This binds escape * to `match-word'. In addition to lots of builtin editor commands, zsh allows you to define your own. The `zle -C' command here creates the match-word editor command. Editor commands which do completion are a little different so they are defined with `zle -C' instead of `zle -N'. To implement a user-defined editor widget, a function has to be written. In this case, we use _generic which is an already existing completion function. _generic hooks in to the existing function based completion system. With it, escape * is now going to behave like a second tab key and do completion. With the zstyle commands we make it behave differently while still doing completion. zstyle is a powerful command which is used for configuring many aspects of completion. It is similar to setting shell options or variables but a particular "style" can have a different value in different contexts. You may have already used zstyle in your startup file. The `completer' style is a very common one. For example, you may use something like: zstyle ':completion:::::' completer _expand _complete _approximate This defines the default completer so will be used for your tab key. This would allow completion to do expansion (expanding file patterns like fred*), then normal completion and then approximate completion (which allows for errors in what you have typed). Above, I used ':completion:match-word::::' as the context. This restricts the style to applying for our new match-word editor command. So escape * now does completion but uses a different set of completers. The important completer in this case was _match. It alone would do the job you were asking about. The other two completers (_all_matches and _ignored) just add some extra functionality. The same goes for the second (match-original) style. That just allows you to go back to the original string you had typed (such as fred*) more easily if completion finds several matches. I hope that makes it clearer. Completion is very configurable and this isn't the simplist example to start with. Oliver