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

Completer help wanted



Hi,

I want to write a _use that lets me complete USE=<tab> on gentoo. I already
have a _gentoo_packages (which I didn't write) that does it for euse and
other commands, with code that looks like this:
_gentoo_packages_update_useflag(){
    local flags PORTDIR
	var=PORTDIR
	[[ -z ${(P)var} && -r /etc/make.conf ]] &&
	    local $var="`. /etc/make.conf 2>/dev/null; echo ${(P)var}`"
	[[ -z ${(P)var} && -r /etc/make.globals ]] &&
	    local $var="`. /etc/make.globals 2>/dev/null; echo ${(P)var}`"

    flags=( ${${(M)${(f)"$(<$PORTDIR/profiles/use.desc)"}:#* - *}%% - *}
    ${${${(M)${(f)"$(<$PORTDIR/profiles/use.local.desc)"}#* - *}%% - *}#*:} )
    compadd $flags
}

I would not be averse to copying it instead of calling it. This is what
I got so far,

#compdef -value-,USE,-default-
_gentoo_packages useflag

But it only completes one useflag and goes away. I want to complete several,
and have them separated by spaces. I looked at the $PATH completer but it uses
internal _path_files magic which didn't help much.

Thanks,

-- 
Mikael Magnusson



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