about summary refs log tree commit diff
path: root/Completion/Base/Core
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:04:49 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:04:49 +0000
commit4285f0578af1958f5a8fc63254ae508bab9468e0 (patch)
treef4ea04b14264e7f91dba42003eee0fd5d327e1a2 /Completion/Base/Core
parent069a04e1046124534575c25eb81576d8679c1785 (diff)
downloadzsh-4285f0578af1958f5a8fc63254ae508bab9468e0.tar.gz
zsh-4285f0578af1958f5a8fc63254ae508bab9468e0.tar.xz
zsh-4285f0578af1958f5a8fc63254ae508bab9468e0.zip
moved from Completion/Core/_tags
Diffstat (limited to 'Completion/Base/Core')
-rw-r--r--Completion/Base/Core/_tags66
1 files changed, 66 insertions, 0 deletions
diff --git a/Completion/Base/Core/_tags b/Completion/Base/Core/_tags
new file mode 100644
index 000000000..0af8d74d2
--- /dev/null
+++ b/Completion/Base/Core/_tags
@@ -0,0 +1,66 @@
+#autoload
+
+local prev
+
+# A `--' as the first argument says that we should tell comptags to use
+# the preceding function nesting level. This is only documented here because
+# if everythings goes well, users won't have to worry about it and should
+# not mess with it.
+
+if [[ "$1" = -- ]]; then
+  prev=-
+  shift
+fi
+
+if (( $# )); then
+
+  # We have arguments: the tags supported in this context.
+
+  local curcontext="$curcontext" order tag nodef tmp
+
+  if [[ "$1" = -C?* ]]; then
+    curcontext="${curcontext%:*}:${1[3,-1]}"
+    shift
+  elif [[ "$1" = -C ]]; then
+    curcontext="${curcontext%:*}:${2}"
+    shift 2
+  fi
+
+  [[ "$1" = -(|-) ]] && shift
+
+  zstyle -a ":completion:${curcontext}:" group-order order &&
+      compgroups "$order[@]"
+
+  # Set and remember offered tags.
+
+  comptags "-i$prev" "$curcontext" "$@"
+
+  # Sort the tags.
+
+  if [[ -n "$_sort_tags" ]]; then
+    "$_sort_tags" "$@"
+  else
+    zstyle -a ":completion:${curcontext}:" tag-order order ||
+        order=('(|*-)argument-* (|*-)option-* values' options)
+
+    for tag in $order; do
+      case $tag in
+      -)     nodef=yes;;
+      \!*)   comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";;
+      ?*)    comptry -m "$tag";;
+      esac
+    done
+
+    [[ -z "$nodef" ]] && comptry "$@"
+  fi
+
+  # Return non-zero if at least one set of tags should be used.
+
+  comptags "-T$prev"
+
+  return
+fi
+
+# The other mode: switch to the next set of tags.
+
+comptags "-N$prev"