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

_hosts and caching wrt zstyle



Hiya, in 

} _hosts () {
}         local expl _hosts tmp useip
}         if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts
}         then
}                 if (( $+_cache_hosts == 0 ))
}                 then
}                         typeset -gUa _cache_hosts
}                         local ipstrip='[:blank:]#[^[:blank:]]#'
}                         zstyle -t ":completion:${curcontext}:hosts" use-ip && useip=yes
}                         [[ -n $useip ]] && ipstrip=
}                         if (( ${+commands[getent]} ))
}                         then
}                                 _cache_hosts=(${(s: :)${(ps:\t:)${(f)~~"$(_call_program hosts getent hosts 2>/dev/null)"}##${~ipstrip}}})

We retrieve the "use-ip" and "command" from zstyle based on the
current completion context, but then the caching seems to be
done regardless of that.

If I have:

zstyle ':completion::complete:ssh:*:hosts' command get-unix-hosts
zstyle ':completion::complete:ssh:*:hosts' use-ip false

zstyle ':completion::complete:rdesktop:*:hosts' command get-windows-hosts
zstyle ':completion::complete:rdesktop:*:hosts' use-ip true

Then, depending on whether I complete ssh or rdesktop first, the
cache will be seeded with unix or windows hosts.

What's the best way to avoid that?

-- 
Stephane



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