From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8271 invoked from network); 8 Jul 2005 10:12:48 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Jul 2005 10:12:48 -0000 Received: (qmail 12173 invoked from network); 8 Jul 2005 10:12:41 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Jul 2005 10:12:41 -0000 Received: (qmail 7332 invoked by alias); 8 Jul 2005 10:12:34 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9059 Received: (qmail 7320 invoked from network); 8 Jul 2005 10:12:33 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Jul 2005 10:12:33 -0000 Received: (qmail 11076 invoked from network); 8 Jul 2005 10:12:33 -0000 Received: from mxfep02.bredband.com (195.54.107.73) by a.mx.sunsite.dk with SMTP; 8 Jul 2005 10:12:27 -0000 Received: from puritan.petwork ([213.112.43.228] [213.112.43.228]) by mxfep02.bredband.com with ESMTP id <20050708101225.ZQKZ21194.mxfep02.bredband.com@puritan.petwork> for ; Fri, 8 Jul 2005 12:12:25 +0200 Received: by puritan.petwork (Postfix, from userid 1000) id 7EEFCADFEA; Fri, 8 Jul 2005 12:12:25 +0200 (CEST) Date: Fri, 8 Jul 2005 12:12:25 +0200 From: Nikolai Weibull To: zsh-users@sunsite.dk Subject: Re: Adding a prefix to certain filename completions Message-ID: <20050708101225.GA5434@puritan.pnetwork> Mail-Followup-To: zsh-users@sunsite.dk References: <20050704193711.GF6330@puritan.pnetwork> <20050705042324.GA21301@picard.franken.de> <20050705080946.GC5333@puritan.pnetwork> <1050706050022.ZM13972@candle.brasslantern.com> <20050706113154.GA5313@puritan.pnetwork> <20050707020210.GA5084@puritan.pnetwork> <1050707054007.ZM14965@candle.brasslantern.com> <20050707105817.GA5452@puritan.pnetwork> <1050708012444.ZM15812@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline In-Reply-To: <1050708012444.ZM15812@candle.brasslantern.com> User-Agent: Mutt/1.5.8i X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Bart Schaefer wrote: > > Done. I modified the function a bit to handle files named + a bit > > better: > I'm not sure this is better. Previously you should have seen the > explanation of 'line number' on the first tab, and then been able to > complete the file name on the second tab. With your change, you'll > never see the 'line number' message, it'll always complete the file. No, that's true. However, when I tried it, I never get to the second group on sucessive tabs (even after an 'emulate zsh'). > But if that's the behavior you wanted, this would be a better way: > > _vim_files () { > case $PREFIX in > (+*) _files -P './' $* && return 0 ;; > (*) _files $* ;; > esac > case $PREFIX in > (+) _message -e 'start at given line (default: end of file)' ;; > (+<->) _message -e 'line number' ;; > esac > } OK, I changed it to that. > Oh, one other thing ... having _vim_files embedded in the file named _vim > in that way, causes _vim_files to be redefined as a function every time > the _vim function is *called*. I should have noticed that before. See > something like _cvs for an example of defining multiple functions in the > same file. Ah, I was looking for examples of completion functions using auxiliary functions and actually saw that, but never got around to adding the redefinition-protection. Thanks. I've included a patch against CVS, nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);} --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="_vim.patch" --- _vim 2005-07-07 14:56:46.000000000 +0200 +++ /home/pcp/.local/etc/zsh/functions/_vim 2005-07-08 12:09:19.936813032 +0200 @@ -1,16 +1,15 @@ #compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff +(( $+functions[_vim_files] )) || _vim_files () { - if [[ $(echo $PREFIX*(N)) == '' ]]; then - case $PREFIX in - (+) _message -e 'start at a given line (default: end of file)' ;; - (+<1->) _message -e 'line number' ;; - esac - fi case $PREFIX in - (+*) _files -P './' $* ;; + (+*) _files -P './' $* && return 0 ;; (*) _files $* ;; esac + case $PREFIX in + (+) _message -e 'start at a given line (default: end of file)' ;; + (+<1->) _message -e 'line number' ;; + esac } local arguments --LZvS9be/3tNcYl/X--