1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

11223: Completion/Base/_regex_arguments, Completion/Debian/_apt,

Completion/X/_xset, Completion/X/_xwit, Doc/Zsh/compsys.yo:
_regex_arguments use _alternative.
This commit is contained in:
Tanaka Akira 2000-05-06 07:59:52 +00:00
parent b3e51a037e
commit c1dc0ffe4f
6 changed files with 158 additions and 103 deletions

View file

@ -1,3 +1,9 @@
2000-05-06 Tanaka Akira <akr@zsh.org>
* 11223: Completion/Base/_regex_arguments, Completion/Debian/_apt,
Completion/X/_xset, Completion/X/_xwit, Doc/Zsh/compsys.yo:
_regex_arguments use _alternative.
2000-05-05 Tanaka Akira <akr@zsh.org> 2000-05-05 Tanaka Akira <akr@zsh.org>
* 11219: Completion/User/_cvs, Completion/User/_diff_options: add * 11219: Completion/User/_cvs, Completion/User/_diff_options: add

View file

@ -81,20 +81,7 @@ _regex_arguments () {
_ra_left="$_ra_line[_ra_p1 + 1, _ra_p2]" _ra_left="$_ra_line[_ra_p1 + 1, _ra_p2]"
_ra_right="$_ra_line[_ra_p2 + 1, -1]" _ra_right="$_ra_line[_ra_p2 + 1, -1]"
compset -p $(( $#PREFIX - $#_ra_line + $_ra_p1 )) compset -p $(( $#PREFIX - $#_ra_line + $_ra_p1 ))
tmp=("${(@)_ra_actions%%:*}") (( $#_ra_actions )) && _alternative "$_ra_actions[@]"
if (( $#tmp )); then
_tags "$tmp[@]"
while _tags; do
for _ra_com in "$_ra_actions[@]"; do
if _requested "${_ra_com%%:*}"; then
while _next_label "${_ra_com%%:*}" expl "${${_ra_com#*:}%%:*}"; do
eval "${_ra_com#*:*:}"
done
[[ nm -ne "$compstate[nmatches]" ]] && break 2
fi
done
done
fi
fi fi
;; ;;
3) _message "invalid regex";; 3) _message "invalid regex";;

View file

@ -50,9 +50,8 @@ _apt_arguments () {
# skip -- # skip --
[[ 0 -lt $# ]] && shift [[ 0 -lt $# ]] && shift
comp_hasarg="\ comp_hasarg="{case \$current_option in
case \$current_option in ${comp_hasarg}esac}"
${comp_hasarg}esac"
local short_seq false true bool bool_prefix intlevel word word1 nul qnul local short_seq false true bool bool_prefix intlevel word word1 nul qnul
local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt
@ -75,13 +74,13 @@ _apt_arguments () {
nul=$'\0' nul=$'\0'
qnul="\$'\\0'" qnul="\$'\\0'"
comp_bool='compadd "$expl[@]" '"$bool" comp_bool="($bool)"
comp_intlevel= #"_message 'intlevel'" comp_intlevel=
comp_configfile='_files "$expl[@]"' comp_configfile='_files'
comp_arbitem= #"_message 'Foo::Bar=bar'" comp_arbitem=
comp_short=\ comp_short=\
'if [[ $PREFIX = -'"$short_seq"' ]]; then '{if [[ $PREFIX = -'"$short_seq"' ]]; then
_apt_consume_short ${PREFIX[2,-1]} _apt_consume_short ${PREFIX[2,-1]}
tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?})
tmp2=(${PREFIX}${^tmp1#-}) tmp2=(${PREFIX}${^tmp1#-})
@ -89,7 +88,7 @@ _apt_arguments () {
elif [[ -z "$PREFIX" ]]; then elif [[ -z "$PREFIX" ]]; then
tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?})
_describe -o option tmp1 _describe -o option tmp1
fi' fi}'
comp_long=\ comp_long=\
'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}" 'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}"
@ -106,7 +105,9 @@ tmp2=("$tmp2[@]" $_ra_left${(M)^short_bool:#$~tmp1} $_ra_left${(M)^short_intleve
tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1}) tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1})
_describe -o option tmp2 -- tmp3 -S=' _describe -o option tmp2 -- tmp3 -S='
comp_opt='{ ! zstyle -T ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }" comp_opt='{{ ! zstyle -T ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }}"
comp_short="{$comp_short}"
comp_long="{$comp_long}"
regex_short=() regex_short=()
regex_long=() regex_long=()

View file

@ -44,67 +44,67 @@ Font Path:
_regex_arguments _xset_parse \ _regex_arguments _xset_parse \
"/$word/" \ "/$word/" \
\( "/-d(isplay|)$nul/" "$guard" "/$word/" ':option-display:display:_x_display "$expl[@]"' \ \( "/-d(isplay|)$nul/" "$guard" "/$word/" ':option-display:display:_x_display' \
\| "/-c$nul/" "$guard" \ \| "/-c$nul/" "$guard" \
\| "/c$nul/" "$guard" \ \| "/c$nul/" "$guard" \
\( "/(on|off)$nul/" ':option-c-bool:click:compadd "$expl[@]" on off' \ \( "/(on|off)$nul/" ':option-c-bool:click:(on off)' \
\| "/[0-9]##$nul/" ':option-c-volume:volume:_message volume' \ \| "/[0-9]##$nul/" ':option-c-volume:volume:' \
\| \) \ \| \) \
\| "/-b$nul/" "$guard" \ \| "/-b$nul/" "$guard" \
\| "/b$nul/" "$guard" \ \| "/b$nul/" "$guard" \
\( "/(on|off)$nul/" ':option-b-bool:bell:compadd "$expl[@]" on off' \ \( "/(on|off)$nul/" ':option-b-bool:bell:(on off)' \
\| "/[0-9]##$nul/" ':option-b-volume:bell volume:_message volume' \ \| "/[0-9]##$nul/" ':option-b-volume:bell volume:' \
\( "/[0-9]##$nul/" ':option-b-pitch:bell pitch:_message pitch' \ \( "/[0-9]##$nul/" ':option-b-pitch:bell pitch:' \
\( "/[0-9]##$nul/" ':option-b-duration:bell duration:_message duration' \ \( "/[0-9]##$nul/" ':option-b-duration:bell duration:' \
\| \) \ \| \) \
\| \) \ \| \) \
\| \) \ \| \) \
\| "/bc$nul/" "$guard" \ \| "/bc$nul/" "$guard" \
\| "/-bc$nul/" "$guard" \ \| "/-bc$nul/" "$guard" \
\| "/fp$nul/" "$guard" "/$word/" ':option-fp:font path:compadd "$expl[@]" default rehash' \ \| "/fp$nul/" "$guard" "/$word/" ':option-fp:font path:(default rehash)' \
\| "/(fp[+=]|[+]fp)$nul/" "$guard" "/$word/" ':option-fp-add:font path:compset -P "*,"; _xset_compfpadd' \ \| "/(fp[+=]|[+]fp)$nul/" "$guard" "/$word/" ':option-fp-add:font path:{compset -P "*,"; _xset_compfpadd}' \
\| "/(fp-|-fp)$nul/" "$guard" "/$word/" ':option-fp-del:font path:compset -P "*,"; _xset_compfpdel' \ \| "/(fp-|-fp)$nul/" "$guard" "/$word/" ':option-fp-del:font path:{compset -P "*,"; _xset_compfpdel}' \
\| "/-led$nul/" "$guard" \ \| "/-led$nul/" "$guard" \
\( "/[0-9]##$nul/" ':option-led-number:led number:_message "led number"' \ \( "/[0-9]##$nul/" ':option-led-number:led number:' \
\| \) \ \| \) \
\| "/led$nul/" "$guard" \ \| "/led$nul/" "$guard" \
\( "/(on|off)$nul/" ':option-led-bool:led:compadd "$expl[@]" on off' \ \( "/(on|off)$nul/" ':option-led-bool:led:(on off)' \
\| "/[0-9]##$nul/" ':option-led-number:led number:_message "led number"' \ \| "/[0-9]##$nul/" ':option-led-number:led number:' \
\| \) \ \| \) \
\| "/m(ouse|)$nul/" "$guard" \ \| "/m(ouse|)$nul/" "$guard" \
\( "/default$nul/" ':option-mouse-default:mouse parameter:compadd "$expl[@]" default' \ \( "/default$nul/" ':option-mouse-default:mouse parameter:(default)' \
\| "/[0-9]##(/[0-9]##|)$nul/" ':option-mouse-mult-div:accel_mult/accel_div:_message accel_mult/accel_div' \ \| "/[0-9]##(/[0-9]##|)$nul/" ':option-mouse-mult-div:accel_mult/accel_div:' \
\( "/[0-9]##$nul/" ':option-mouse-threshold:threshold:_message threshold' \ \( "/[0-9]##$nul/" ':option-mouse-threshold:threshold:' \
\| \) \ \| \) \
\| \) \ \| \) \
\| "/[-+]dpms$nul/" "$guard" \ \| "/[-+]dpms$nul/" "$guard" \
\| "/dpms$nul/" "$guard" \ \| "/dpms$nul/" "$guard" \
\( "/[0-9]##$nul/" ':option-dpms-standby:standby timeout:_message "standby timeout"' \ \( "/[0-9]##$nul/" ':option-dpms-standby:standby timeout:' \
\( "/[0-9]##$nul/" ':option-dpms-suspend:suspend timeout:_message "suspend timeout"' \ \( "/[0-9]##$nul/" ':option-dpms-suspend:suspend timeout:' \
\( "/[0-9]##$nul/" ':option-dpms-off:off timeout:_message "off timeout"' \ \( "/[0-9]##$nul/" ':option-dpms-off:off timeout:' \
\| \) \ \| \) \
\| \) \ \| \) \
\| "/force/" ':option-dpms-force:force DPMS state:compadd "$expl[@]" force' \ \| "/force$nul/" ':option-dpms-force:force DPMS state:(force)' \
"/(on|standby|suspend|off)$nul/" ':option-dpms-state:DPMS state:compadd "$expl[@]" on standby suspend off' \ "/(on|standby|suspend|off)$nul/" ':option-dpms-state:DPMS state:(on standby suspend off)' \
\) \ \) \
\| "/s$nul/" "$guard" \ \| "/s$nul/" "$guard" \
\( "/(blank|noblank|expose|noexpose|default|on|activate|reset)$nul/" \ \( "/(blank|noblank|expose|noexpose|default|on|activate|reset)$nul/" \
':option-s:screen saver:compadd "$expl[@]" blank noblank expose noexpose default on activate reset off' \ ':option-s:screen saver:(blank noblank expose noexpose default on activate reset off)' \
\| "/off$nul/" \( "/off$nul/" ':option-s-off-period:period off:compadd "$expl[@]" off' \| \) \ \| "/off$nul/" \( "/off$nul/" ':option-s-off-period:period off:(off)' \| \) \
\| "/[0-9]##$nul/" ':option-s-timeout:length:_message length' \ \| "/[0-9]##$nul/" ':option-s-timeout:length:' \
\( "/[0-9]##$nul/" ':option-s-period:period:_message period' \ \( "/[0-9]##$nul/" ':option-s-period:period:' \
\| \) \ \| \) \
\| \) \ \| \) \
\| "/-r$nul/" "$guard" \ \| "/-r$nul/" "$guard" \
\( "/[0-9]##$nul/" ':option-r-keycode:keycode:_message keycode' \ \( "/[0-9]##$nul/" ':option-r-keycode:keycode:' \
\| \) \ \| \) \
\| "/r$nul/" "$guard" \ \| "/r$nul/" "$guard" \
\( "/(on|off)$nul/" ':option-r-autorepeat:autorepeat:compadd "$expl[@]" on off' \ \( "/(on|off)$nul/" ':option-r-autorepeat:autorepeat:(on off)' \
\| "/[0-9]##$nul/" ':option-r-keycode:keycode:_message keycode' \ \| "/[0-9]##$nul/" ':option-r-keycode:keycode:' \
\| \) \ \| \) \
\| "/p$nul/" "$guard" \ \| "/p$nul/" "$guard" \
"/[0-9]##$nul/" ':option-p-pixel:pixel:_message pixel' \ "/[0-9]##$nul/" ':option-p-pixel:pixel:' \
"/$word/" ':option-p-color:color:_x_color "$expl[@]"' \ "/$word/" ':option-p-color:color:_x_color' \
\| "/(-|)k$nul/" "$guard" \ \| "/(-|)k$nul/" "$guard" \
\| "/(-|)q$nul/" "$guard" \ \| "/(-|)q$nul/" "$guard" \
\| "/[]/" ':options:options:_xset_compopts' \ \| "/[]/" ':options:options:_xset_compopts' \

View file

@ -3,7 +3,7 @@
local word=$'[^\0]#\0' local word=$'[^\0]#\0'
local nul=$'\0' local nul=$'\0'
local guard='-_xwit_guard -${match[1]%?}' local guard='-_xwit_guard ${match[1]%?}'
_xwit_guard () { _xwit_guard () {
local opt="$1" o local opt="$1" o
@ -15,58 +15,108 @@ _xwit_guard () {
} }
_xwit_compopts () { _xwit_compopts () {
compadd "$expl[@]" - ${(k)no[(R)*~0]} || local expl
compadd "$expl[@]" - ${(k)no} local opt tmp
tmp=()
for opt in ${(k)no[(R)*~0]}
do
if (( $+desc[$opt] )); then
tmp=("$tmp[@]" "$opt:$desc[$opt]")
else
tmp=("$tmp[@]" "$opt")
fi
done
_describe -o options tmp -- ||
_describe -o options allopts --
# compadd "$expl[@]" - ${(k)no[(R)*~0]} ||
# compadd "$expl[@]" - ${(k)no}
} }
_regex_arguments _xwit_parse \ _regex_arguments _xwit_parse \
"/$word/" \ "/$word/" \
\( \ \( "/-display$nul/" "$guard" "/$word/" ':option-display:display:_x_display' \
"/-/+" \ \| "/-(sync|pop|open|iconify|unmap|root|current|select|(no|)(save|backingstore|saveunder))$nul/" "$guard" \
\( "/display$nul/" "$guard" "/$word/" ':option-display:display:_x_display' \ \| "/-resize$nul/" "$guard" \
\| "/(sync|pop|open|iconify|unmap|root|current|select|(no|)(save|backingstore|saveunder))$nul/" "$guard" \ "/$word/" ':option-resize-width:width:' \
\| "/resize$nul/" "$guard" \ "/$word/" ':option-resize-height:height:' \
"/$word/" ':option-resize-width:width:_message width' \ \| "/-rows$nul/" "$guard" "/$word/" ':option-rows:rows:' \
"/$word/" ':option-resize-height:height:_message height' \ \| "/-columns$nul/" "$guard" "/$word/" ':option-columns:columns:' \
\| "/rows$nul/" "$guard" "/$word/" ':option-rows:rows:_message rows' \ \| "/-move$nul/" "$guard" \
\| "/columns$nul/" "$guard" "/$word/" ':option-columns:columns:_message columns' \ "/$word/" ':option-move-x:x:' \
\| "/move$nul/" "$guard" \ "/$word/" ':option-move-y:y:' \
"/$word/" ':option-move-x:x:_message x' \ \| "/-rmove$nul/" "$guard" \
"/$word/" ':option-move-y:y:_message y' \ "/$word/" ':option-rmove-x:x:' \
\| "/rmove$nul/" "$guard" \ "/$word/" ':option-rmove-y:y:' \
"/$word/" ':option-rmove-x:x:_message x' \ \| "/-warp$nul/" "$guard" \
"/$word/" ':option-rmove-y:y:_message y' \ "/$word/" ':option-warp-x:x:' \
\| "/warp$nul/" "$guard" \ "/$word/" ':option-warp-y:y:' \
"/$word/" ':option-warp-x:x:_message x' \ \| "/-rwarp$nul/" "$guard" \
"/$word/" ':option-warp-y:y:_message y' \ "/$word/" ':option-rwarp-x:x:' \
\| "/rwarp$nul/" "$guard" \ "/$word/" ':option-rwarp-y:y:' \
"/$word/" ':option-rwarp-x:x:_message x' \ \| "/-colormap$nul/" "$guard" \
"/$word/" ':option-rwarp-y:y:_message y' \ "/$word/" ':option-colormap:colormapid:_x_colormapid' \
\| "/colormap$nul/" "$guard" \ \| "/-(name|label)$nul/" "$guard" \
"/$word/" ':option-colormap:colormapid:_x_colormapid' \ "/$word/" ':option-name:name:_x_name' \
\| "/(name|label)$nul/" "$guard" \ \| "/-iconname$nul/" "$guard" \
"/$word/" ':option-name:name:_x_name "$expl[@]"' \ "/$word/" ':option-name:iconname:_x_name' \
\| "/iconname$nul/" "$guard" \ \| "/-bitmap$nul/" "$guard" \
"/$word/" ':option-name:iconname:_x_name "$expl[@]"' \ "/$word/" ':option-bitmap:bitmap file:_files -g *.xbm' \
\| "/bitmap$nul/" "$guard" \ \| "/-mask$nul/" "$guard" \
"/$word/" ':option-bitmap:bitmap file:_files "$expl[@]" -g \*.xbm' \ "/$word/" ':option-mask:mask file:_files -g *.xbm' \
\| "/mask$nul/" "$guard" \ \| "/-iconmove$nul/" "$guard" \
"/$word/" ':option-mask:mask file:_files "$expl[@]" -g \*.xbm' \ "/$word/" ':option-iconmove-x:x:' \
\| "/iconmove$nul/" "$guard" \ "/$word/" ':option-iconmove-y:y:' \
"/$word/" ':option-iconmove-x:x:_message x' \ \| "/-id$nul/" "$guard" "/$word/" ':option-id:window id:_x_window' \
"/$word/" ':option-iconmove-y:y:_message y' \ \| "/-(no|)keyrepeat$nul/" "$guard" \
\| "/id$nul/" "$guard" "/$word/" ':option-id:window id:_x_window' \ \( "/[0-9]##$nul/" ':option-keyrepeat-keycode:keycode:{[[ -prefix [0-9]# ]] && _message keycode}' \
\| "/(no|)keyrepeat$nul/" "$guard" \ \( "/-$nul/" "/[0-9]##$nul/" \
\( "/[0-9]##$nul/" ':option-keyrepeat-keycode:keycode:[[ -prefix [0-9]# ]] && _message keycode' \ ':option-keyrepeat-last-keycode:last keycode:{[[ -prefix [0-9]# ]] && _message "last keycode"}' \| \) \) \# \
\( "/-$nul/" "/[0-9]##$nul/" ':option-keyrepeat-last-keycode:last keycode:[[ -prefix [0-9]# ]] && _message "last keycode"' \| \) \) \# \ \| "/-names$nul/" "$guard" \
\| "/names$nul/" "$guard" \ "/$word/" ':option-names:window name:_x_window -n' \# \
"/$word/" ':option-names:window name:_x_window -n' \# \ \| "/[]/" ':options:option:_xwit_compopts' \
\| "/[]/" ':options:option:_xwit_compopts' \
\) \
\) \# \) \#
_xwit () { _xwit () {
typeset -A no eo local expl allopts
typeset -A desc no eo
desc=(
-display 'specify display'
-sync 'synchronous mode'
-pop 'pop up window'
-open 'pop up window'
-iconify 'iconify window'
-unmap 'iconify window by unmapping'
-root 'select the root window'
-current 'select the window under current pointer'
-select 'select the window interactively'
-save 'activate screen saver'
-backingstore 'enable backingstore'
-saveunder 'enable saveunder'
-nosave 'reset screen saver'
-nobackingstore 'disable backingstore'
-nosaveunder 'disable saveunder'
-resize 'resize window'
-rows 'resize window rows'
-columns 'resize window columns'
-move 'move window'
-rmove 'move window relatively'
-warp 'warp pointer'
-rwarp 'warp pointer relatively'
-colormap 'install colormap'
-name 'specify window name'
-label 'specify window name'
-iconname 'specify icon name'
-bitmap 'specify icon bitmap'
-mask 'specify icon mask'
-iconmove 'move icon'
-id 'select the window by window-ID'
-keyrepeat 'enable keyrepeat'
-nokeyrepeat 'disable keyrepeat'
-names 'select the window by name'
)
no=( no=(
-display 1 -display 1
@ -102,6 +152,16 @@ _xwit () {
-names 1 -names 1
) )
allopts=()
for opt in ${(k)no}
do
if (( $+desc[$opt] )); then
allopts=("$allopts[@]" "$opt:$desc[$opt]")
else
allopts=("$allopts[@]" "$opt")
fi
done
eo=( eo=(
-root '-root -current -select -id -names' -root '-root -current -select -id -names'
-current '-root -current -select -id -names' -current '-root -current -select -id -names'

View file

@ -3292,11 +3292,12 @@ right.
If no test succeeds and the remaining command line string contains no null If no test succeeds and the remaining command line string contains no null
character, the completion target is restricted to the remainder of the character, the completion target is restricted to the remainder of the
command line string and var(action)s for the target are evaluated. command line string and var(action)s for the target are executed.
In this case, nothing is actually removed from the command line string In this case, nothing is actually removed from the command line string
so that any previous or neighbouring state may also have var(actions)s. so that any previous or neighbouring state may also have var(actions)s.
var(actions)s evaluation are ordered by the tt(tag-order) style and var(actions)s evaluation are ordered by the tt(tag-order) style and specified
specified var(tag). var(descr) is used for set up the array parameter var(tag) by tt(_alternative). So, various format supported by tt(_alternative)
can be used in var(action). var(descr) is used for set up the array parameter
tt(expl). tt(expl).
) )
item(tt(/)var(pattern)tt(/+) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(tag)tt(:)var(descr)tt(:)var(action)])( item(tt(/)var(pattern)tt(/+) [tt(%)var(lookahead)tt(%)] [tt(-)var(guard)] [tt(:)var(tag)tt(:)var(descr)tt(:)var(action)])(