From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16495 invoked from network); 27 Oct 2004 14:52:51 -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:52:51 -0000 Received: (qmail 37827 invoked from network); 27 Oct 2004 14:52:39 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Oct 2004 14:52:39 -0000 Received: (qmail 11947 invoked by alias); 27 Oct 2004 14:52:13 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8134 Received: (qmail 11859 invoked from network); 27 Oct 2004 14:52:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Oct 2004 14:52:11 -0000 Received: (qmail 34445 invoked from network); 27 Oct 2004 14:52:11 -0000 Received: from ns9.hostinglmi.net (213.194.149.146) by a.mx.sunsite.dk with SMTP; 27 Oct 2004 14:52:10 -0000 Received: from 212.red-80-35-44.pooles.rima-tde.net ([80.35.44.212]:40520 helo=dervishd.net) by ns9.hostinglmi.net with esmtpa (Exim 4.43) id 1CMp9i-0004NJ-KD; Wed, 27 Oct 2004 16:52:07 +0200 Date: Wed, 27 Oct 2004 16:54:44 +0200 From: DervishD To: Oliver Kiddle Cc: Zsh Users Subject: Re: compsys issues Message-ID: <20041027145444.GB10003@DervishD> Mail-Followup-To: Oliver Kiddle , Zsh Users References: <20041027132610.GA9928@DervishD> <15603.1098886106@trentino.logica.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <15603.1098886106@trentino.logica.co.uk> User-Agent: Mutt/1.4.2.1i Organization: DervishD X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns9.hostinglmi.net X-AntiAbuse: Original Domain - sunsite.dk X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - dervishd.net X-Source: X-Source-Args: X-Source-Dir: 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 Hi Oliver :) * Oliver Kiddle dixit: > > # 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. OK, but that doesn't solve the problem I explained below. And I assumed that I must use $PREFIX :? I don't understand why I must remove the last path element from PREFIX :? > > 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. Done, but then I'm presented the same list again and again: $ cd Projects/ Projects Work ... I see, I need more tweaking. I'll keep on reading... > > 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. First error I made, then. I did something like this: compset -P '*/' compadd -f - $IPREFIX$PREFIX*(/) > 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) I tried to do something like that but it didn't work. I don't know what my mistake was, I'm afraid... > 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 works perfectly, thanks a lot :) The only part I didn't understand was the -W flag. I mean, the manual says this flag adds the string to the WORDS, and I though that the process was: - compadd expands the pattern and build a list of words - compadd matches the words with the current word being completed - compadd produces a list of matches - the contents of -W is added to THAT list But if I understand correctly, the string that follows '-W' is added *before* compadd does the matching, am I wrong? > Hope that helps It *really* helps, thanks a lot, Oliver :) Only one more thing, abusing of you O:). I get a segfault under 4.0.9 (probably it is fixed in newer versions) if I do this: zle -C expand-or-complete expand-or-complete _completer function _completer () { emulate -L zsh setopt extendedglob globdots globassign null_glob compstate[insert]=${compstate[insert]//tab /} compadd -p 'A' -f - $PREFIX*(/) return 0 } and I do something like 'cd A '. Do you know why? Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.dervishd.net & http://www.pleyades.net/