From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7274 invoked from network); 11 Feb 2009 18:28:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Feb 2009 18:28:24 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 56219 invoked from network); 11 Feb 2009 18:28:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Feb 2009 18:28:19 -0000 Received: (qmail 6438 invoked by alias); 11 Feb 2009 18:28:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26552 Received: (qmail 6422 invoked from network); 11 Feb 2009 18:28:16 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 11 Feb 2009 18:28:16 -0000 Received: from lorien.comfychair.org (lorien.comfychair.org [64.81.241.43]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 9215B80271F0 for ; Wed, 11 Feb 2009 19:28:09 +0100 (CET) Received: from lorien.comfychair.org (lorien [127.0.0.1]) by lorien.comfychair.org (8.14.3+Sun/8.14.3) with ESMTP id n1BISA19023921 for ; Wed, 11 Feb 2009 10:28:10 -0800 (PST) Received: (from duvall@localhost) by lorien.comfychair.org (8.14.3+Sun/8.14.3/Submit) id n1BIS9ZH023920 for zsh-workers@sunsite.dk; Wed, 11 Feb 2009 10:28:09 -0800 (PST) Date: Wed, 11 Feb 2009 10:28:08 -0800 From: Danek Duvall To: zsh-workers@sunsite.dk Subject: completion based on context earlier in the line Message-ID: <20090211182808.GA20929@lorien.comfychair.org> Mail-Followup-To: Danek Duvall , zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-27) X-Virus-Scanned: ClamAV 0.92.1/8980/Wed Feb 11 17:40:45 2009 on bifrost X-Virus-Status: Clean I'm having trouble figuring out how to do this. I've got a command, "svccfg", which can look roughly like: svccfg -s describe I'm trying to figure out how to complete , but it has to be based on , and I've no idea how to get the value of to the property completion function. My _svccfg looks roughly like this (the full thing is in the zsh distro): if [[ $service == "svccfg" ]]; then _arguments -s \ '-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \ \ '*::command:->subcmd' && return 0 if (( CURRENT == 1 )); then _wanted return fi service="$words[1]" curcontext=... fi case $service in (describe) _arguments -A "-*" \ ":property:_smf_properties" So I want to extract the argument to -s (if it exists) and pass it to _smf_properties down below. But I don't know how. As above, by the time I get past the first _arguments, $words no longer has any words prior to the subcommand, so I can't go digging through there for it. And my attempts to use '*:command:->subcmd' (i.e., the single-colon version that doesn't reset CURRENT and words) and emulate the double-colon version after extracting the information have failed. Perhaps I just haven't gotten it right yet. I could do like _tar does, and check for the argument to -s before I even get into the first _arguments, but that seems a bit sketchy, as I'd really like to be sure to get the one before the subcommand, rather than any -s flag that might happen after the subcommand. Are there any examples I could crib from? Can anyone offer any other help? Thanks, Danek