about summary refs log tree commit diff
path: root/Completion/User/_exec_funcs
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-23 10:07:17 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-23 10:07:17 +0000
commitf7fa32f091420552d5dbb16ff5f574484508f1de (patch)
tree82be5f077e6cdddad82a015f77a0308d825cd951 /Completion/User/_exec_funcs
parent16060224ac17a8b5a1efb8568643f9a15b14c034 (diff)
downloadzsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.gz
zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.xz
zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.zip
zsh-workers/7463
Diffstat (limited to 'Completion/User/_exec_funcs')
-rw-r--r--Completion/User/_exec_funcs49
1 files changed, 49 insertions, 0 deletions
diff --git a/Completion/User/_exec_funcs b/Completion/User/_exec_funcs
new file mode 100644
index 000000000..2fd64b230
--- /dev/null
+++ b/Completion/User/_exec_funcs
@@ -0,0 +1,49 @@
+#autoload
+
+# This should be called from `_arguments' or otherwise the calling
+# function has to set up an array named `line' that contains the
+# name of the executable as its seconf element or it has to supply
+# that name as an argument.
+# One option is recognized: `-p' means that we are completing a pair
+# of names separated by a slash.
+
+local cmd pair expl
+
+if [[ "$1" = -p ]]; then
+  pair=yes
+  shift
+fi
+
+if (( $# )); then
+  cmd="$1"
+elif [[ $#line -gt 1 ]]; then
+  cmd="$line[2]"
+else
+  return 1
+fi
+
+if [[ -n "$cmd" ]]; then
+  if [[ "$cmd" = /* ]]; then
+    tmp="$cmd"
+  else
+    tmp="$PWD/$cmd"
+  fi
+
+  if [[ "$tmp" != "$_es_command" ]]; then
+    _es_command="$tmp"
+    _es_funcs=( "${(@)${(@M)${(@f)$(nm $cmd)}:#[^ ]# [tT] ([^_]|_[^_])*}##* }" )
+  fi
+  
+  if [[ -n "$pair" ]]; then
+    if compset -P '*/'; then
+      _description expl 'call arc to function'
+    else
+      _description expl 'call arc from function'
+    fi
+  else
+    _description expl function
+  fi
+  compadd -M 'r:|_=* r:|=*' - "$_es_funcs[@]"
+else
+  return 1
+fi