From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7022 invoked from network); 4 Nov 2004 02:20:47 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Nov 2004 02:20:47 -0000 Received: (qmail 80205 invoked from network); 4 Nov 2004 02:20:41 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Nov 2004 02:20:41 -0000 Received: (qmail 5255 invoked by alias); 4 Nov 2004 02:19:51 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8158 Received: (qmail 5241 invoked from network); 4 Nov 2004 02:19:50 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Nov 2004 02:19:50 -0000 Received: (qmail 79016 invoked from network); 4 Nov 2004 02:19:50 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 4 Nov 2004 02:19:48 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id iA42JlJ8013225 for ; Wed, 3 Nov 2004 18:19:47 -0800 Date: Wed, 3 Nov 2004 18:19:47 -0800 (PST) From: Bart Schaefer Reply-To: Bart Schaefer To: Zsh Users Subject: Re: Filename expansion within a completion widget In-Reply-To: <20041102234409.GB21654@DervishD> Message-ID: References: <20041102233658.GA21654@DervishD> <20041102234409.GB21654@DervishD> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 On Wed, 3 Nov 2004, DervishD wrote: > > compset -P '*/' > > > > Well, it handles both relative and absolute directories > > correctly, but doesn't handle named directories :(( I don't > > understand why because if I type 'cd ~X' the named dir should be > > expanded, shouldn't it? "Expanded" would mean that ~X was replaced by the path it represents. Yet later you say this isn't the behavior you want. If the variable is really $X11, for example, then converting ~X to ~X11 is not "expanding", it's "completing", at least in zsh's terminology (e.g., for purposes of the widget "expand-or-complete"). And if you've written your own completion widget, you have to do the completing yourself, right? > Of course, adding something like 'PREFIX=$~PREFIX' just before > the compset call solves the problem, but then the named dir is > 'translated', which I don't want Just because you're not using zsh's completion system functions doesn't mean you can't look at them for hints. Completion/Unix/Type/_tilde_files would be a good place to start; note in particular the case statement on $PREFIX. > There is surely another way of doing this... The short answer is that if there is not a slash in the string yet, you remove the tilde from consideration with compset -P, and then you compadd the userdirs and/or nameddirs arrays from the zsh/parameter module. If there is a slash in the string, you have to manipulate IPREFIX and then use compadd -W.