about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:09:51 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:09:51 +0000
commita5509ebb04f1f045e285af849bbf1cbe865a1a33 (patch)
tree3c8446eaeee4855945d0bcc8bc7b35e331c6d738 /Completion
parent917188675aba132371494b45c2ee1a70254cb59a (diff)
downloadzsh-a5509ebb04f1f045e285af849bbf1cbe865a1a33.tar.gz
zsh-a5509ebb04f1f045e285af849bbf1cbe865a1a33.tar.xz
zsh-a5509ebb04f1f045e285af849bbf1cbe865a1a33.zip
moved from Completion/Base/_cache_invalid
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Utility/_cache_invalid21
1 files changed, 21 insertions, 0 deletions
diff --git a/Completion/Base/Utility/_cache_invalid b/Completion/Base/Utility/_cache_invalid
new file mode 100644
index 000000000..e55381439
--- /dev/null
+++ b/Completion/Base/Utility/_cache_invalid
@@ -0,0 +1,21 @@
+#autoload
+#
+# Function to decide whether a completions cache needs rebuilding
+
+local _cache_ident _cache_dir _cache_path _cache_policy
+_cache_ident="$1"
+
+# If the cache is disabled, we never want to rebuild it, so pretend
+# it's valid.
+zstyle -t ":completion:${curcontext}:" use-cache || return 1
+
+zstyle -s ":completion:${curcontext}:" cache-path _cache_dir
+: ${_cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache}
+_cache_path="$_cache_dir/$_cache_ident"
+
+# See whether the caching policy says that the cache needs rebuilding
+# (the policy will return 0 if it does).
+zstyle -s ":completion:${curcontext}:" cache-policy _cache_policy
+[[ -n "$_cache_policy" ]] && "$_cache_policy" "$_cache_path" && return 0
+
+return 1