about summary refs log tree commit diff
path: root/Completion/Base/Utility
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:11:36 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:11:36 +0000
commit3a4ef1f0db69b8642d3b6aa81b376d8b63a4b4bd (patch)
tree4742941ba6782349f3ce7d232d0d87e3920e22bd /Completion/Base/Utility
parent7df6561d5036e3a9ca139f45f7b6aeb23f826780 (diff)
downloadzsh-3a4ef1f0db69b8642d3b6aa81b376d8b63a4b4bd.tar.gz
zsh-3a4ef1f0db69b8642d3b6aa81b376d8b63a4b4bd.tar.xz
zsh-3a4ef1f0db69b8642d3b6aa81b376d8b63a4b4bd.zip
moved from Completion/Base/_store_cache
Diffstat (limited to 'Completion/Base/Utility')
-rw-r--r--Completion/Base/Utility/_store_cache36
1 files changed, 36 insertions, 0 deletions
diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache
new file mode 100644
index 000000000..2fe7dfcb6
--- /dev/null
+++ b/Completion/Base/Utility/_store_cache
@@ -0,0 +1,36 @@
+#autoload
+#
+# Storage component of completions caching layer
+
+local _cache_ident
+_cache_ident="$1"
+
+if zstyle -t ":completion:${curcontext}:" use-cache; then
+  # Decide which directory to cache to, and ensure it exists
+  zstyle -s ":completion:${curcontext}:" cache-path _cache_dir
+  : ${_cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache}
+  if [[ ! -d "$_cache_dir" ]]; then
+    if [[ -e "$_cache_dir" ]]; then
+      _message "cache-dir style points to a non-directory\!"
+    else
+      mkdir -p "$_cache_dir"
+      if [[ ! -d "$_cache_dir" ]]; then
+        _message "Couldn't create cache-dir $_cache_dir"
+        return 1
+      fi
+    fi
+  fi
+
+  shift
+  for var; do
+    case ${(Pt)var} in
+    (*readonly*) ;;
+    (*(association|array)*) print -r "$var=( ${(kv@Pqq)^^var} )";;
+    (*)                     print -r "$var=${(Pqq)^^var}";;
+    esac
+  done >! "$_cache_dir/$_cache_ident"
+else
+  return 1
+fi
+
+return 0