about summary refs log tree commit diff
path: root/Completion/Core/_normal
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:05:38 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:05:38 +0000
commite74702b467171dbdafb56dfe354794a212e020d9 (patch)
treec295b3e9b2e93e2de10331877442615b0f37e779 /Completion/Core/_normal
parentc175751b501a3a4cb40ad4787340a597ea769be4 (diff)
downloadzsh-e74702b467171dbdafb56dfe354794a212e020d9.tar.gz
zsh-e74702b467171dbdafb56dfe354794a212e020d9.tar.xz
zsh-e74702b467171dbdafb56dfe354794a212e020d9.zip
Initial revision
Diffstat (limited to 'Completion/Core/_normal')
-rw-r--r--Completion/Core/_normal54
1 files changed, 54 insertions, 0 deletions
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
new file mode 100644
index 000000000..19da6d79b
--- /dev/null
+++ b/Completion/Core/_normal
@@ -0,0 +1,54 @@
+#autoload
+
+local comp cmd1 cmd2 pat val name
+
+# Completing in command position? If not we set up `cmd1' and `cmd2' as
+# two strings we have search in the completion definition arrays (e.g.
+# a path and the last path name component).
+
+if [[ $CONTEXT == command ]]; then
+  comp="$_comps[-command-]"
+  [[ -z "$comp" ]] || "$comp" "$@"
+  return
+elif [[ "$COMMAND[1]" == '=' ]]; then
+  eval cmd1\=$COMMAND
+  cmd2="$COMMAND[2,-1]"
+elif [[ "$COMMAND" == */* ]]; then
+  cmd1="$COMMAND"
+  cmd2="${COMMAND:t}"
+else
+  cmd1="$COMMAND"
+  eval cmd2=$(whence -p $COMMAND)
+fi
+
+# See if there are any matching pattern completions.
+
+for i in "$_patcomps[@]"; do
+  pat="${i% *}"
+  val="${i#* }"
+  if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
+    "$val" "$@"
+    if (( $+_compskip )); then
+      unset _compskip
+      return
+    fi
+  fi
+done
+
+# Now look up the two names in the normal completion array.
+
+name="$cmd1"
+comp="$_comps[$cmd1]"
+
+if [[ -z "$comp" ]]; then
+  name="$cmd2"
+  comp="$_comps[$cmd2]"
+fi
+
+# And generate the matches, probably using default completion.
+
+if [[ -z "$comp" ]]; then
+  name=-default-
+  comp="$_comps[-default-]"
+fi
+[[ -z "$comp" ]] || "$comp" "$@"