From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6293 invoked from network); 22 Mar 2001 18:58:31 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Mar 2001 18:58:31 -0000 Received: (qmail 25070 invoked by alias); 22 Mar 2001 18:58:15 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3727 Received: (qmail 25054 invoked from network); 22 Mar 2001 18:58:14 -0000 From: John Cooper To: zsh-users@sunsite.dk Subject: need help to convert final compctl! Organization: Citrix Systems Date: 22 Mar 2001 19:05:05 +0000 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii With the old compctl system, I used the functions below to be able to complete *arbitrary substrings* from a list of commonly used directories. For example, typing the following: $ `g pd' .. would yield: $ g module/pd module/pd module/pd/encrypt module/pd/rframe from which I could complete further or accept the choice with RET. (the `g' command doesn't _require_ completion; typing `g clip' automatically tries to find a matching directory from the dirs list (and in this case will change directory to $JICA/module/vd/clipboard)). I've now switched to the new completion system and this is my only remaining compctl, so I wondered how I can achieve the same thing with the new system? Thanks, --- John dirs=( ui/applet ui/application module/vd/printer module/td/tcp browse module module/pd module/pd/encrypt module/pd/rframe module/td module/td/SOCKS module/vd module/vd/ProgramNeighborhood module/vd/audio module/vd/ccm module/vd/clipboard module/vd/printer/LprStream module/vd/printer/lpr module/vd/thinwire module/wd module/wd/ica30 pn pn/UI pn/UI/AWT widgets pn/UI/AWT/customwidgets pn/help ui ui/application/cui ui/application/cutil ui/application/gjt ui/application/help ui/test capability ) # function for matching above directories from an arbitrary substring. g () { destination=$dirs[(r)*$1*] cd $JICA/client/$destination ls } # Completion function for the above function dirCompleter () { typeset -i count=1 elt=$dirs[(n:count:r)*$1$2*] reply=($elt) until [ "$elt" = "" ] do count=$count+1 elt=$dirs[(n:count:r)*$1$2*] reply=($reply $elt) done } compctl -U -K dirCompleter g