Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: starting completions with =,<,>



On Sun, 25 Jul 2004 10:42:38 -0700, Bart Schaefer wrote:


> Unless you "unsetopt equals" this could potentially be expanded into
>
> emerge -p /usr/local/bin/zsh-4.2.0-r1
>
> (or the like).  That's why there's the "-equals-" completion context.

Yes, I saw that, it's in my example under the compdef header. Is it
-equal- or -equals- though? And are there any examples of this anywhere? I
saw that _bzip2 uses -redirect-, but it wasn't obvious how to apply that
to my situation with -equal-. There doesn't seem to be any command that
does use -equal-, that I've found.

>> I saw in the manpage that _values does not support the equal sign.
> 
> Can you quote the bits of the manual that made you think this?
>
>
Sure, the man page for zshcompsys says this under _values 6th paragraph

  All other arguments describe the possible values and their arguments 
  in the same format used for the description of options by the _arguments
  function (see above).  The only  differences  are that  no minus or plus
  sign is required at the beginning, values can have only one argument,
  and the forms  of  action  beginning with an equal sign are not
  supported.

I'm probably reading it wrong, though.

> In any event I don't think you want _values.  The _values function is
> for words of the form <name><sep><value> where <sep> defaults to "=",
> e.g. "foo=bar" (like an assignment).  You can tell it to use a different
> <sep>, but in the case of emerge there doesn't appear to be a <name>
> part.

Exactly, there is no <name>, just a <value>.
 
> The problem here is that you're trying to treat this as an option, when
> what you need to do is treat it as an argument.  The question is whether
> it is a stand-alone argument, or whether it's an argument that must
> follow the -p option?  I haven't been able to dig up any documentation
> on emerge (the only software I can find are a mass-mailing program and
> the emacs CVS interface -- everything else is lost in the Google noise
> because "emerge" is a real word).

Sorry for not being more clear. Emerge is the gentoo linux install
command. You can find out more about gentoo at www.gentoo.org.  There is a
manpage here: http://re.a.la/man/emerge/ What I am trying to add is listed
under the ebuild and dependency headers.

This could be a standalone argument, or it could follow one or more other
arguments (-p, --pretend, --update, etc...). 
emerge -p =gvim-6.3
emerge  =gvim-6.3
emerge --pretend --deep --buildpkg =gvim-6.3 
All valid commands as far as emerge is concerned.

The existing emerge completion is here: 
http://cpan.cybercomm.nl/pub/gentoo-portage/app-shells/zsh/files/_portage

If I insert this snippet (along with the _portage_ebuilds from my previous
example) into the above completion, --pretend works and lists all the
appropriate files, while = lists the normal ones.
 
 =|--pretend)
  _arguments -s \
     '*:install version:_portage_ebuilds' "$common_args[@]" && return 0
		;;

And just to clarify, I want regular emerge without an equal sign to
complete one list (fvwm, zsh, abiword...) and the emerge = to complete
exact versions (fvwm-2.5.10-r6, fvwm-2.4.18, zsh-4.2.0-r1, ...). So I
can't just replace the default behavior with the versioned packages.

Hope that clears things up. Thanks for looking at this.



Messages sorted by: Reverse Date, Date, Thread, Author