mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-26 01:41:14 +01:00
Redo _zle using _arguments; fix typos.
This commit is contained in:
parent
5c7a14857a
commit
9e9457f30e
4 changed files with 84 additions and 11 deletions
|
@ -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.
|
||||
|
|
|
@ -1,10 +1,77 @@
|
|||
#compdef zle
|
||||
|
||||
local expl
|
||||
local expl ret=1 st
|
||||
local -a opts compwids state
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue