about summary refs log tree commit diff
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
parent5c7a14857a89265c0e311a1438c94375abe18cbe (diff)
downloadzsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.tar.gz
zsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.tar.xz
zsh-9e9457f30e9146a175f5a1e0e0e81686a6ee9852.zip
Redo _zle using _arguments; fix typos.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Builtins/_zle83
-rw-r--r--Doc/Zsh/compwid.yo3
-rw-r--r--Doc/Zsh/mod_zle.yo6
4 files changed, 85 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 29eb17fe8..2c397f67c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-09-11  Bart Schaefer  <schaefer@brasslantern.com>
+
+	* 12793: Completion/Builtins/_zle, Doc/Zsh/compwid.yo,
+	Doc/Zsh/mod_zle.yo: Convert _zle to use _arguments; fix typos.
+
 2000-09-08  Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
 
 	* 12779: Src/system.h: Comment out #define _XPG_IV for sinix.
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
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 99a1d6aa4..bc72926ca 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -640,7 +640,8 @@ in turn matches what is on the line.  If the var(n)'th var(word) does not
 match, the var(n)'th element of the var(array) is removed.  Elements
 for which the corresponding var(word) is matched are retained.
 )
-item(tt(-), tt(--))(
+xitem(tt(-))
+item(tt(-)tt(-))(
 This flag ends the list of flags and options. All arguments after it
 will be taken as the words to use as matches even if they begin with
 hyphens.
diff --git a/Doc/Zsh/mod_zle.yo b/Doc/Zsh/mod_zle.yo
index 3b4d58ed7..dd658a858 100644
--- a/Doc/Zsh/mod_zle.yo
+++ b/Doc/Zsh/mod_zle.yo
@@ -190,7 +190,7 @@ cindex(widgets, calling)
 cindex(calling widgets)
 cindex(widgets, defining)
 cindex(defining widgets)
-xitem(tt(zle) tt(-l) [ tt(-L) ] [ tt(-a) ] [ var(string) ... ])
+xitem(tt(zle) tt(-l) [ tt(-L) | tt(-a) ] [ var(string) ... ])
 xitem(tt(zle) tt(-D) var(widget) ...)
 xitem(tt(zle) tt(-A) var(old-widget) var(new-widget))
 xitem(tt(zle) tt(-N) var(widget) [ var(function) ])
@@ -204,7 +204,7 @@ The tt(zle) builtin performs a number of different actions concerning
 ZLE.  Which operation it performs depends on its options:
 
 startitem()
-item(tt(-l) [ tt(-L) ])(
+item(tt(-l) [ tt(-L) | tt(-a) ])(
 List all existing user-defined widgets.  If the tt(-L)
 option is used, list in the form of tt(zle)
 commands to create the widgets.
@@ -238,7 +238,7 @@ ifzman(zmanref(zshzle))\
 ifnzman(noderef(Zsh Line Editor))\
 .
 )
-citem(completion widgets, creating)
+cindex(completion widgets, creating)
 item(tt(-C) var(widget) var(completion-widget) var(function))(
 Create a user-defined completion widget named var(widget). The 
 completion widget will behave like the built-in completion-widget