Zsh Mailing List Archive
Messages sorted by:
Re: starting completions with =,<,>
- X-seq: zsh-workers 20209
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: chris s <oberyno@xxxxxxxxx>
- Subject: Re: starting completions with =,<,>
- Date: Mon, 26 Jul 2004 15:59:20 +0200
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <pan.2004.07.26.13.06.54.327306@xxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <pan.2004.07.25.11.42.39.666502@xxxxxxxxx> <Pine.LNX.4.61.0407250838430.7539@xxxxxxxxxxxxxxxxxx> <pan.2004.07.25.21.39.37.858165@xxxxxxxxx> <pan.2004.07.26.13.06.54.327306@xxxxxxxxx>
chris s wrote:
> Ok, I was looking more into this, and it turns out the bash completion is
> able to handle =, >=,<=. The bash person did this:
That sort of approach wouldn't work in zsh. It does a lot of the work
for you when it comes to quoting.
In the previous e-mail:
> emerge -p =zsh-4.2.0-r1
> emerge -p '>zsh-4.2.0'
> emerge -p '<zsh-4.2.0'
> emerge -p '>=zsh-4.2.0'
> emerge -p zsh
> are all valid commands. I saw in the manpage that _values does not
> support the equal sign. Unfortunately, that's exactly what I need.
I looked at your script and it is using _arguments. It's a bit messy to
handle the quoting. Try the following as a starting point:
_arguments -C \
'--pretend[pretend an emerge]' \
'--exact[specify exact version]' \
case $state in
if compset -P '(\\|)[<=>]*'; then
compadd zsh-4.2.0-r1 etc etc
_values -S '' 'version prefix' \
'=[specify exact version]:' \
'<[specify maximum version]:' \
'>[specify too old version]:' \
'>=[specify minimum version]:'
compadd zsh etc etc
You'll need to put a proper tags loop around the bit with _values and
the other compadd. I'm not really using _values in the way it was
intended but this does work.
Note that you probably shouldn't be using the :*: stuff in _arguments.
Look inside the opt_args associative array from inside the args state
You don't need to do anything with the -equals- context. You just need
to either write:
emerge -p \=zsh-4.2.0-r1 (or emerge -p '=zsh-4.2.0-r1')
or use unsetopt equals in your setup. This applies regardless of any
completion function setup. This is what the emerge man page means when
it says "in many shells you will need to escape characters such as '<'
Messages sorted by: