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

Re: _values and specifying -M to compadd



On Mon, Sep 24, 2007 at 10:24:25AM +0100, Peter Stephenson wrote:

> _values is designed to be smart about the values of key/value pairs,
> whereas you need something to be smart about the keys.  (_values is
> also a bit of a mess because the internals are delegated to a builtin
> "compvalues" which is only documented in the C source.)

Yeah, that stymied me.  :)  I wasn't all that intent into diving into the C
source.  Though if it's well commented, I might take a look anyway.

> Actually, using compadd directly isn't that hairy here.  I got this to work:

Wonderful.  I was missing the compset bits, and while I might have
eventually stumbled on the first, I probably wouldn't have gotten the
second.

The only thing remaining is to remove already-completed tokens, which I'm
doing with a simple loop over IPREFIX:

    for t in ${(s:,:)${IPREFIX//\\#\!/}}; do
        tokens=( ${tokens:#$t} )
    done

before passing tokens on to compadd.  It looked like there wasn't any
special magic in _values that did this, but it's sufficiently poorly
commented that I wasn't sure exactly where this was happening.

You can't think of a fruit starting with "e" either, eh?  :)

Thanks!
Danek



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