From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2981 invoked from network); 30 Jul 2006 21:14:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Jul 2006 21:14:08 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88700 invoked from network); 30 Jul 2006 21:14:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Jul 2006 21:14:02 -0000 Received: (qmail 8161 invoked by alias); 30 Jul 2006 21:13:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22566 Received: (qmail 8151 invoked from network); 30 Jul 2006 21:13:58 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Jul 2006 21:13:58 -0000 Received: (qmail 88405 invoked from network); 30 Jul 2006 21:13:58 -0000 Received: from mta08-winn.ispmail.ntl.com (HELO mtaout02-winn.ispmail.ntl.com) (81.103.221.48) by a.mx.sunsite.dk with SMTP; 30 Jul 2006 21:13:56 -0000 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20060730211355.MAKF27023.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sun, 30 Jul 2006 22:13:55 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout01-winn.ispmail.ntl.com with ESMTP id <20060730211354.JELW644.aamtaout01-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sun, 30 Jul 2006 22:13:54 +0100 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.7/8.13.7) with ESMTP id k6ULDoJC031090 for ; Sun, 30 Jul 2006 22:13:51 +0100 Message-Id: <200607302113.k6ULDoJC031090@pwslaptop.csr.com> From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: env -u completion doesn't work when there is a command In-Reply-To: Message from Bart Schaefer of "Sun, 30 Jul 2006 11:36:01 PDT." <060730113601.ZM13458@torch.brasslantern.com> Date: Sun, 30 Jul 2006 22:13:50 +0100 Bart Schaefer wrote: > On Jul 30, 8:00pm, Vincent Lefevre wrote: > } > } env -u LIBR[TAB] gcc > } > } where the cursor is after LIBR, the completion doesn't work. > > This is a generalized problem with _arguments, in that there's no way > to specify that an option (-u in this case) has a mandatory argument > that must be in a separate word. I'm not sure it's that, since using the specification '-u+:env var to remove:compadd ${(k)parameters[(R)*export*]}' doesn't seem to fix it. This should says that if there's no option immediately after the -u there must be one in the next word, which would cover the current case. It seems comparguments -O is returning false, causing _arguments to think there are no more arguments to complete. comparguments is defined in zsh/computil and is documented thus: comparguments This is used by the _arguments function to do the argument and command line parsing. Like compdescribe it has an option -i to do the parsing and initialize some internal state and various options to access the state information to decide what should be completed. Right. Slightly more helpfully, the code for comparguments -O says: /* This returns the descriptions for the options in the arrays whose * names are given as arguments. The descriptions are strings in a * form usable by _describe. The return value says if there are any * options to be completed. */ so I would guess this is looking at the wrong word to decide if there are options to be completed, since we're getting to _tags "$subcs[@]" at _arguments:219 instead of _tags "$subcs[@]" options at _arguments:217. However, as that's the only comment it's hard to tell. Actually, "$subcs[@]" expands to argument-rest, so maybe it's comparguments -D, which sets subcs, that's too blame. The comment for that says /* This returns the descriptions, actions and sub-contexts for the * things _arguments has to execute at this place on the line (the * sub-contexts are used as tags). * The return value is particularly important here, it says if * there are arguments to completely at all. */ The argument-rest comes from ca_set_data(), an uncommented 91-line function that does the guts of comparguments -D. This uses the state originally set up by comparguments -i, however. comparguments -i calls ca_parse_line() which has a few comments suggesting it might be searching for options and arguments. I think that might be the place to start. But who knows? -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/