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

_expand_word_and_keep of 'keeper suite' doesn't work



Greetings,

The version of _expand_word_and_keep below (from the magazine
article) doesn't seem to work in at least 4.2.5.  For some reason
the condition [[ $args[-J] == all-expansions ]] is never true when
and nothing is put to the kept variable.  I have no idea of what that
condition is there for, but just for the heck of it I tried
removing it completely.  Then, ... *.jpg<C-x e> caused *.jpg to be
put to the kept variable.

Any ideas?

_expand_word_and_keep() {
    function compadd() {
        local -A args
        zparseopts -E -A args J:
        if [[ $args[-J] == all-expansions ]]; then
            builtin compadd -A kept "$@"
            kept=( ${(Q)${(z)kept}} )
        fi
        builtin compadd "$@"
    }
    local result
    _main_complete _expand
    result=$?
    unfunction compadd
    return result
}

zle -C _expand_word complete-word _expand_word_and_keep

-- 
Hannu



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