From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6343 invoked from network); 7 Jul 2005 05:40:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Jul 2005 05:40:44 -0000 Received: (qmail 45742 invoked from network); 7 Jul 2005 05:40:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Jul 2005 05:40:36 -0000 Received: (qmail 14533 invoked by alias); 7 Jul 2005 05:40:28 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9043 Received: (qmail 14524 invoked from network); 7 Jul 2005 05:40:27 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Jul 2005 05:40:27 -0000 Received: (qmail 44586 invoked from network); 7 Jul 2005 05:40:27 -0000 Received: from vms042pub.verizon.net (206.46.252.42) by a.mx.sunsite.dk with SMTP; 7 Jul 2005 05:40:23 -0000 Received: from candle.brasslantern.com ([71.116.88.149]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IJ800EN9T388213@vms042.mailsrvcs.net> for zsh-users@sunsite.dk; Thu, 07 Jul 2005 00:40:21 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j675eDgN014967 for ; Wed, 06 Jul 2005 22:40:19 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j675e85d014966 for zsh-users@sunsite.dk; Wed, 06 Jul 2005 22:40:08 -0700 Date: Thu, 07 Jul 2005 05:40:07 +0000 From: Bart Schaefer Subject: Re: Adding a prefix to certain filename completions In-reply-to: <20050707020210.GA5084@puritan.pnetwork> To: zsh-users@sunsite.dk Message-id: <1050707054007.ZM14965@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050705172846.GB5362@puritan.pnetwork> <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> Comments: In reply to Nikolai Weibull "Re: Adding a prefix to certain filename completions" (Jul 7, 4:02am) 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=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 [Aside: Is it possible for you to convince your mail client not to send text labeled us-ascii when it contains multi-byte characters (I think they must be Unicode apostrophes?) It makes it quite difficult to read. I've manually edited them back to ' in the excerpt.] On Jul 7, 4:02am, Nikolai Weibull wrote: } Subject: Re: Adding a prefix to certain filename completions } } There's a problem with the + option, though. I couldn't figure out } a proper way of escaping the + that is the options name (just using \+ } doesn't work). The + is not the option's name. The name is whatever comes *after* the initial - or + that introduces the option. In fact, in this case + is not really an option at all; really it's a non-option argument that happens to be allowed to be mixed in among the options. The most effective way to handle it is to rewrite _my_files: _my_files () { case $PREFIX in (+) _message -e 'start at given line (default: end of file)' ;; (+<1->) _message -e 'line number' ;; esac case $PREFIX in (+*) _files -P './' $* ;; (*) _files $* ;; esac } Another way is to pretend that the number is the option name: arguments=( ... +{1..9}-'[start at given line (default: end of file)]::line number: ' ... ) I prefer the behavior of the modified _my_files (which, by the way, should probably be renamed _vim_files if this is going to be added to the stock completions).