From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18134 invoked from network); 13 Jul 2001 17:03:38 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Jul 2001 17:03:38 -0000 Received: (qmail 18856 invoked by alias); 13 Jul 2001 17:03:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15392 Received: (qmail 18841 invoked from network); 13 Jul 2001 17:03:29 -0000 From: "Bart Schaefer" Message-Id: <1010713170109.ZM1620@candle.brasslantern.com> Date: Fri, 13 Jul 2001 17:01:08 +0000 In-Reply-To: <200107130807.KAA00965@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: long/short options" (Jul 13, 10:07am) References: <200107130807.KAA00965@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (5.0.0 30July97) To: Sven Wischnowsky , zsh-workers@sunsite.dk Subject: Re: long/short options MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jul 13, 10:07am, Sven Wischnowsky wrote: } Subject: Re: long/short options } } Andrej Borsenkow wrote: } } > ... } > } > What I'd really like is something like } > } > -b, --binary -- Unix line endings } > ... } > } > Or do I miss something and this is already possible? } } It isn't. And it's hard to write (but that didn't stop us in the past). } One would have to change the way comparguments stores and reports the } options and one would have to change the code in _describe to list } things differently. I would thing that the real reason it's difficult is because of menu- selection. If the options get lumped together like that, where should the select-cursor go, and what should it insert on the command line? You'd have to decide that e.g. its not possible to menu-select the one- letter version of the option, or some such. Anyway, that aside, obviously it would require a change to _describe, but would it really need a change in the C code? Taking this fragment as an example: _arguments -s \ '(-b -t --text)--binary[Unix line endings LF]' \ '(--binary -t --text)-b[Unix line endings LF]' One solution would be to have _describe actually scan the description strings looking for duplicates, and condense them in the listing by adding one option to the display string for the other and dropping the duplicate from the list of completions (i.e., the duplicate would get passed to `compadd -n ...'). That would have the effect I mentioned, that you'd see `-b, --binary ...' but only be able to menu-select `--binary'. That still means the caller of _arguments has to supply all the duplicate description strings for _describe to search for. So another possibility would be for the caller to use something like: _arguments -s \ '(-b -t --text)--binary[Unix line endings LF]' \ '(--binary -t --text)-b[(--binary)]' Here _describe would parse off the leading parenthesized string from the description. If the option named in the parens is among the possible completions, it prepends the option name and a comma to the description string of the option named in the parens and uses `compadd -n' for the option that has this special description. Otherwise it adds the option and the rest of the description (after the parens) as usual. [This is to handle a strange special case where you have two options that mean the same thing individually but have different exclusion lists, e.g. one of them has a new meaning when in combination with some third option.] Both of these approaches mean that _describe has to make an extra pass over the options before `compadd'ing them. And I'm really not sure how difficult they actually would be to implement. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net