From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10343 invoked from network); 7 Sep 1999 09:49:24 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 Sep 1999 09:49:24 -0000 Received: (qmail 495 invoked by alias); 7 Sep 1999 09:49:11 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7685 Received: (qmail 485 invoked from network); 7 Sep 1999 09:49:10 -0000 Date: Tue, 7 Sep 1999 10:49:01 +0100 From: Adam Spiers To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: completion for perldoc Message-ID: <19990907104901.C7292@thelonious.new.ox.ac.uk> Reply-To: Adam Spiers Mail-Followup-To: zsh-workers@sunsite.auc.dk References: <199909070832.KAA03607@beta.informatik.hu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <199909070832.KAA03607@beta.informatik.hu-berlin.de>; from Sven Wischnowsky on Tue, Sep 07, 1999 at 10:32:00AM +0200 X-URL: http://www.new.ox.ac.uk/~adam/ X-OS: Linux 2.2.9 i686 Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote: > Adam Spiers wrote: > > - Why can't you have multiple MESSAGE:ACTION pairs with the > > *:MESSAGE:ACTION form? I'm having to resort to using an auxiliary > > function, e.g.: > > There three forms that allow you to specify completion for > (non-option-) arguments: [snip] Sorry, badly phrased question. I understood the three forms; my question was, why can't the third form: > `*:mesg:action' > specify completion for `all other' arguments look like this: `*:mesg1:action1:mesg2:action2:...' ? So that instead of this (which now works!) ... _perldoc () { _arguments -s \ '-h:help:' \ '(-q)-f:Perl built-in function:_perl_builtin_funcs' \ '(-f)-q:Perl FAQ keyword:' \ '*:Perl pod pages:_perl_pods' } _perl_pods () { local nm="$compstate[nmatches]" _perl_modules _perl_basepods _path_files -J 'Perl modules and .pods' -/ -g '*.(pod|pm)' [[ nm -ne "$compstate[nmatches]" ]] } I could do something like: _perldoc () { _arguments -s \ '-h:help:' \ '(-q)-f:Perl built-in function:_perl_builtin_funcs' \ '(-f)-q:Perl FAQ keyword:' \ '*:Perl modules:_perl_modules:Perl base pods:_perl_basepods:Perl modules and .pods:_path_files -/ -g \*.\(pod\|pm\)' } > > - Is it possible to do something like (-foo)*:MESSAGE:ACTION, i.e. > > specifying completion for normal args only if -foo hasn't been > > specified? > > There is no direct support for this. I'm not sure what you really want > to have, but I think (or: hope) you can do it with: > > `-foo:*:mesg1:action1' '*:mesg2:action2' > > which makes *all* arguments after the option `-foo' be completed > with `action1' (if that is empty, nothing will be completed, of > course), and if `-foo' is not given, the second specification will > be used > > This can then be used together with some trickery for `action1' to > achieve almost everything. If that is not enough or too clumsy to use, > I'd like to see the real world example that made you wish for this. > And then I'll think about ways to make this easier. The example I'm thinking of is (surprise, surprise) perldoc. The word after -f is now correctly completed to Perl's built-in functions. However, I want to prevent further completions if `-f print ' (say) has been typed in, since `perldoc -f print Perl::Module' is nonsensical to perldoc. `(-q)-f:built-in function:_perl_builtin_func:*:' works, but `(-f)-q:FAQ keyword::*:' gets confused by the empty ACTION. I tried `(-f)-q:FAQ keyword:():*:' but then it doesn't print `FAQ keyword'.