Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: long/short options
- X-seq: zsh-workers 15392
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: long/short options
- Date: Fri, 13 Jul 2001 17:01:08 +0000
- In-reply-to: <200107130807.KAA00965@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200107130807.KAA00965@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author