From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10192 invoked from network); 27 Oct 2004 14:10:14 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 Oct 2004 14:10:14 -0000 Received: (qmail 8290 invoked from network); 27 Oct 2004 14:10:04 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Oct 2004 14:10:04 -0000 Received: (qmail 24151 invoked by alias); 27 Oct 2004 14:09:54 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8133 Received: (qmail 24140 invoked from network); 27 Oct 2004 14:09:54 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Oct 2004 14:09:54 -0000 Received: (qmail 4348 invoked from network); 27 Oct 2004 14:08:54 -0000 Received: from mail36.messagelabs.com (193.109.254.211) by a.mx.sunsite.dk with SMTP; 27 Oct 2004 14:08:48 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-8.tower-36.messagelabs.com!1098886126!10617616 X-StarScan-Version: 5.2.10; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 26966 invoked from network); 27 Oct 2004 14:08:46 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-8.tower-36.messagelabs.com with SMTP; 27 Oct 2004 14:08:46 -0000 Received: from trentino.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id i9RE8kn6027299 for ; Wed, 27 Oct 2004 15:08:46 +0100 Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id 583BE223B4 for ; Wed, 27 Oct 2004 16:08:26 +0200 (CEST) X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <20041027132610.GA9928@DervishD> From: Oliver Kiddle References: <20041027132610.GA9928@DervishD> To: Zsh Users Subject: Re: compsys issues Date: Wed, 27 Oct 2004 16:08:26 +0200 Message-ID: <15603.1098886106@trentino.logica.co.uk> X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 DervishD wrote: > # expand-or-complete is currently bound to > zle -C expand-or-complete expand-or-complete _completer > > function _completer () { > > compstate[insert]=${compstate[insert]//tab /} > > compadd -f - $PREFIX*(/) I realise that it is there to get any preceding directory portion but you're overriding the internal matching by starting the pattern match with $PREFIX. I'd use something like ${(M)PREFIX##*/} instead. > Let's say I pick 'Projects' and hit tab again. Now I'm presented > with this: > > $ cd Projects/ > > Projects/mta/ Projects/zsh-things/ Projects/more/ > > But what I want is to be presented with: > > $ cd Projects/ > > mta/ zsh-things/ more/ For that, you need to use compset -P '*/' to move the initial directory portions to $IPREFIX so they are not part of matching. > I've tried tweaking IPREFIX and PREFIX (with and without the help > from compset), I've tried generating the list of matches before You need to tweak the compadd command too. After compset, any initial directory portion will be in $IPREFIX instead of $PREFIX. That will include a trailing slash so you can do $IPREFIX*(/) to get the files. That will now try to add stuff like `Projects/more' as a match when `Projects/' is in IPREFIX. You don't want to include the stuff in $IPREFIX in the possible matches so you can use the :t modifier to get just the filenames as matches: $IPREFIX*(/:t) Next, you need to use compadd's -W option so that the -f option can find the right directory. Try something like the following to begin with: compadd -W $PWD/$IPREFIX -f - $IPREFIX*(/:t) That won't work with paths starting with variable expansions or non-relative directories. You'll need more logic to work out the argument to -W. Using $~IPREFIX will help resolve any expansions on the command line. Hope that helps Oliver