summary refs log tree commit diff
path: root/Completion/Builtins/_zle
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2000-09-11 07:08:27 +0000
committerBart Schaefer <barts@users.sourceforge.net>2000-09-11 07:08:27 +0000
commit9e9457f30e9146a175f5a1e0e0e81686a6ee9852 (patch)
tree00a59e587cecf2fcafa23cb23644fba6d71539c6 /Completion/Builtins/_zle
parent5c7a14857a89265c0e311a1438c94375abe18cbe (diff)
downloadzsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.tar.gz
zsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.tar.xz
zsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.zip
Redo _zle using _arguments; fix typos.
Diffstat (limited to 'Completion/Builtins/_zle')
-rw-r--r--Completion/Builtins/_zle83
1 files changed, 75 insertions, 8 deletions
diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle
index e390382d4..8a84b3697 100644
--- a/Completion/Builtins/_zle
+++ b/Completion/Builtins/_zle
@@ -1,10 +1,77 @@
 #compdef zle
 
-local expl
-
-if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
-  _wanted -C -N functions expl 'widget shell function' \
-      compadd "$@" -k functions
-else
-  _wanted widgets expl widget compadd -k widgets
-fi
+local expl ret=1 st
+local -a opts compwids state
+
+compwids=(accept-and-menu-complete
+	  complete-word
+	  delete-char-or-list
+	  expand-or-complete
+	  expand-or-complete-prefix
+	  list-choices
+	  menu-complete
+	  menu-expand-or-complete
+	  reverse-menu-complete)
+
+opts=(-A -C -D -L -M -N -R -U -a -c -l \* :)
+
+_arguments -s \
+    "($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \
+    "($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \
+    "($opts)-D[delete widget]:*:widget:->widget" \
+    "(${opts#-l})-L+[with -l, list as commands]:*:-:->listing" \
+    "(${opts#-[La]})-l+[list user-defined widgets]:*:-:->listing" \
+    "(${opts#-l})-a+[with -l, list all widgets]:*:-:->listing" \
+    "($opts)-M[display message]:message: " \
+    "($opts)-N[define new widget]:widget name:->widget-or-function ::widget shell function:->function" \
+    "(${opts#-c})-R+[redisplay]:*:-:->redisplay" \
+    "(${opts#-R})-c+[with -R, clear listing]:*:-:->redisplay" \
+    "($opts)-U[unget to input stack]:string: " \
+    '(-)::widget name:->call'
+
+[[ $state == listing ]] &&
+  _arguments -s \
+    "-l[list user-defined widgets]" \
+    "(-a)-L[list as commands]" \
+    "(-L)-a[list all widgets]" \
+    '(-)*:widget name:->widget'
+
+for st in $state; do
+  case $st in
+    (call)
+      if ((CURRENT > 2)); then
+	_arguments \
+          '(-N)-n[numeric prefix]:number: ' \
+	  '(-n)-N[reset numeric prefix]' \
+	  ':widget::' '(-)*:widget arguments: ' && ret=0
+	  # :widget:: is a placeholder so we needn't shift words
+	continue
+      fi
+      ;&
+    (widget*)
+      _wanted widgets expl widget compadd -k widgets && ret=0
+      [[ $st != *function ]] && continue
+      ;&
+    (function)
+      _wanted functions expl 'widget shell function' \
+	compadd -k functions && ret=0
+      ;;
+    (comp-widget)
+      _wanted widgets expl 'completion widget' \
+	compadd -k "widgets[(R)(*:|)(.|)(${(j(|))compwids})(|:*)]" && ret=0
+      ;&
+    (builtin-comp-widget)
+      _wanted widgets expl 'builtin completion widget' \
+	compadd -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0
+      ;;
+    (redisplay)
+      _arguments -s \
+        "-R[redisplay]" \
+	"(*)-c[clear listing]" \
+	"(-)::status line: " "*:strings to list: " && ret=0
+      ;;
+    (*) ret=$?;;
+  esac
+done
+
+return ret