summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-23 23:56:26 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-23 23:56:26 +0000
commit21c6aca81618cbf75c81101293c0e1b3b62b10d5 (patch)
tree5e3b25d62935d8c342a305b38ad3ea0620a23444 /Completion/Core
parent44cff5e0ea5e77e0188a151d92a20cb3006c039b (diff)
downloadzsh-21c6aca81618cbf75c81101293c0e1b3b62b10d5.tar.gz
zsh-21c6aca81618cbf75c81101293c0e1b3b62b10d5.tar.xz
zsh-21c6aca81618cbf75c81101293c0e1b3b62b10d5.zip
Initial revision
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_loop44
-rw-r--r--Completion/Core/_try24
2 files changed, 68 insertions, 0 deletions
diff --git a/Completion/Core/_loop b/Completion/Core/_loop
new file mode 100644
index 000000000..fa7118ec4
--- /dev/null
+++ b/Completion/Core/_loop
@@ -0,0 +1,44 @@
+#autoload
+
+local gopt=-J len tmp pre suf tloop ret=1 descr
+
+if [[ "$1" = -t ]]; then
+  tloop=yes
+  shift
+fi
+if [[ "$1" = -([12]|)[VJ] ]]; then
+  gopt="$1"
+  shift
+fi
+
+tmp=${argv[(ib:4:)-]}
+len=$#
+if [[ tmp -lt len ]]; then
+  pre=$(( tmp-1 ))
+  suf=$tmp
+elif [[ tmp -eq $# ]]; then
+  pre=-2
+  suf=$(( len+1 ))
+else
+  pre=4
+  suf=5
+fi
+
+while [[ -z "$tloop" ]] || comptags -N; do
+  while comptags -A "$1" curtag; do
+    if [[ "$curtag" = *:* ]]; then
+      zformat -f descr "${curtag#*:}" "d:$3"
+      _description "$gopt" "${curtag%:*}" "$2" "$descr"
+      curtag="${curtag%:*}"
+
+      "$4" "${(P@)2}" "${(@)argv[5,-1]}"
+    else
+      _description "$gopt" "$curtag" "$2" "$3"
+
+      "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0
+    fi
+  done
+  [[ -z "$tloop" || ret -eq 0 ]] && break
+done
+
+return ret
diff --git a/Completion/Core/_try b/Completion/Core/_try
new file mode 100644
index 000000000..e309e53ea
--- /dev/null
+++ b/Completion/Core/_try
@@ -0,0 +1,24 @@
+#autoload
+
+local gopt=-J descr
+
+if [[ "$1" = -([12]|)[VJ] ]]; then
+  gopt="$1"
+  shift
+fi
+
+if comptags -A "$1" curtag; then
+  if [[ "$curtag" = *:* ]]; then
+    zformat -f descr "${curtag#*:}" "d:$3"
+    _description "$gopt" "${curtag%:*}" "$2" "$descr"
+    curtag="${curtag%:*}"
+    eval "${2}=( \${(P)2} \$argv[4,-1] )"
+  else
+    _description "$gopt" "$curtag" "$2" "$3"
+    eval "${2}=( \$argv[4,-1] \${(P)2} )"
+  fi
+
+  return 0
+fi
+
+return 1