From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14060 invoked by alias); 22 Oct 2015 16:40:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36918 Received: (qmail 4105 invoked from network); 22 Oct 2015 16:40:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:user-agent; bh=GH6V/z0SOFECJNZac9z/ip1P6h14rT/sOqquE4H/fCg=; b=yfAtJomgpEk+4Se7XX1N52i9w7iLmzrMl4PjALAMtHBydaTF0SInZ2uKiOJ7dOzKnP cp4vTjZy9bWOxm5h7ak8MzsrFEPr6kuYfQPhAlzpEBYcmz7cm6imiaOerc4O6+Wnfr2R kMjraPNQFAbNDERa/boSbGEWy6nB7tk//FkyEyN4EcYe0c0TJgyf5b+MVf8c7V2brHZq oZ3g9di1IwzFDKut/yMPm9mOe2UlU22RWOOUgXEfIY1/GLUfiw3+ROLN6lMxLBsx5+0F 11CGIZehyPVI4o4LD9J+2HWgjFvY4a6QXRwmpV1XIxcW9aEwIDUDottOadYRHvGb4Tui cU9g== X-Received: by 10.180.108.13 with SMTP id hg13mr19176877wib.91.1445532035834; Thu, 22 Oct 2015 09:40:35 -0700 (PDT) Date: Thu, 22 Oct 2015 17:40:34 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: _hosts and caching wrt zstyle Message-ID: <20151022164034.GB6713@chaz.gmail.com> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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