zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: chris s <oberyno@gmail.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: starting completions with =,<,>
Date: Mon, 26 Jul 2004 15:59:20 +0200	[thread overview]
Message-ID: <7532.1090850360@trentino.logica.co.uk> (raw)
In-Reply-To: <pan.2004.07.26.13.06.54.327306@gmail.com>

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]' \
    '*: :->args'

  case $state in
    args)
      if compset -P '(\\|)[<=>]*'; then
	compadd zsh-4.2.0-r1 etc etc
      else
	_values -S '' 'version prefix' \
	  '=[specify exact version]:' \
	  '<[specify maximum version]:' \
	  '>[specify too old version]:' \
	  '>=[specify minimum version]:'
	compadd zsh etc etc
      fi
    ;;
  esac

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
instead.

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 '<'
and '='"

Oliver


      reply	other threads:[~2004-07-28  3:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-25 11:42 chris s
2004-07-25 17:42 ` Bart Schaefer
2004-07-25 21:39   ` chris s
2004-07-26 13:06     ` chris s
2004-07-26 13:59       ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7532.1090850360@trentino.logica.co.uk \
    --to=okiddle@yahoo.co.uk \
    --cc=oberyno@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).