Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: a few completion function changes
- X-seq: zsh-workers 17522
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: PATCH: a few completion function changes
- Date: Fri, 09 Aug 2002 17:00:00 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: kiddleo@xxxxxxxxxx
Just a few changes I had collected up:
complete for tkinfo in _texinfo too. Perhaps this should have it's own
function in which case we'd also have to factor out an _info_nodes?
a typo in _wget,
allowing localhost specified as an IP in _urls (further to Clint's recent
changes),
modify _apt-show-versions to use the option grouping by descriptions
clean up _cdcd, fixing such things as sorting track listings numerically
and the fact that it tried to use _arguments for everything.
Oliver
Index: Completion/Debian/Command/_apt-show-versions
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_apt-show-versions,v
retrieving revision 1.1
diff -u -r1.1 _apt-show-versions
--- Completion/Debian/Command/_apt-show-versions 3 Jan 2002 03:39:24 -0000 1.1
+++ Completion/Debian/Command/_apt-show-versions 9 Aug 2002 15:56:33 -0000
@@ -1,21 +1,12 @@
#compdef apt-show-versions
_arguments \
- '(--status-file)-stf[status file]:status file:_files' \
- '(-stf)--status-file=:status file:_files' \
- '(--list-dir)-ld[aptlist dir]:aptlist dir:_files -/' \
- '(-ld)--list-dir=:aptlist dir:_files -/' \
- '(--package)-p[package]:package:_deb_packages avail' \
- '(-p)--package=:package:_deb_packages avail' \
- '(--regex)-r[regex]' \
- '(-r)--regex' \
- '(--upgradeable)-u[print only upgradeable packages]' \
- '(-u)--upgradeable' \
- '(--allversions)-a[print all available versions]' \
- '(-a)--allversions' \
- '(--brief)-b[brief output]' \
- '(-b)--brief' \
- '(--verbose)-v[verbose output]' \
- '(-v)--verbose' \
- '(--help)-h[help]' \
- '(-h)--help'
+ '(--status-file -stf)'{--status-file=,-stf}'[specify dpkg status file]:status file:_files' \
+ '(--list-dir -ld)'{--list-dir=,-ld}"[specify dir for apt's list files]:apt list dir:_files -/" \
+ '(--package -p)'{--package=,-p}'[restrict to specified package]:package:_deb_packages avail' \
+ '(--regex -r)'{--regex,-r}'[interpret -p argument as regex]' \
+ '(--upgradeable -u)'{--upgradeable,-u}'[print only upgradeable packages]' \
+ '(--allversions -a)'{--allversions,-a}'[print all available versions]' \
+ '(--brief -b)'{--brief,-b}'[brief output]' \
+ '(--verbose -v)'{--verbose,-v}'[verbose output]' \
+ '(--help -h)'{--help,-h}'[display help information]'
Index: Completion/Unix/Command/_cdcd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_cdcd,v
retrieving revision 1.2
diff -u -r1.2 _cdcd
--- Completion/Unix/Command/_cdcd 17 Feb 2002 16:46:12 -0000 1.2
+++ Completion/Unix/Command/_cdcd 9 Aug 2002 15:56:33 -0000
@@ -1,66 +1,57 @@
#compdef cdcd
-typeset -A opt_args
+local expl
_cdcd_tracks ()
{
- print ${${${(f)"$(cdcd info)"}[3]}/Total tracks: #(#b)([0-9]##)*/$match[1]}
-}
-
-_cdcd_track_list ()
-{
- print ${1..$(_cdcd_tracks)}
-}
-
-_cdcd_track_list_verbose ()
-{
- print ${${(M)${(f)"$(cdcd tracks)"}:#(#s) #[0-9]##:*}/(#s) #(#b)([0-9]##):[ >]#? #[^ ]# #(*) ##/$match[1]:${(qqq)match[2]}}
+ local -a tracks
+ tracks=( ${${(M)${(f)"$(cdcd tracks)"}:#(#s) #[0-9]##:*}/(#s) #(#b)([0-9]##):[ >]#? #[^ ]# #(*) ##/$match[1]:${match[2]}} )
+ _describe tracks tracks -V tracks
}
_cdcd_commands ()
{
- _arguments \
- ':cdcd command:((
- play\:"play a track"
- stop\:"stop plating"
- open\:"eject the CD-ROM tray"
- eject\:"eject the CD-ROM tray"
- close\:"close the CD-ROM tray"
- pause\:"pause playing"
- resume\:"resume playing"
- ff\:"fast forward"
- rew\:"rewind"
- next\:"advance one track"
- prev\:"return to previous track"
- getvol\:"get current volume settings"
- setvol\:"set volume settings"
- status\:"get numerical data regarding the CD status"
- info\:"short information about the CD"
- tracks\:"list all tracks on the CD"
- rndplay\:"play a random track"
- list\:"list all CDs in a CD-ROM changer"
- slot\:"changes the current CD in the CD-ROM changer"
- edit\:"edit information about the disc"
- ext\:"Extended information about the disc"
- refresh\:"refresh the information about the CD from a CDDB server"
- device\:"change the CD-ROM device cdcd will use"
- verbose\:"toggle verbosity"
- sites\:"edit the server list"
- access\:"configure cddb access method"
- help\:"display a help message"
- ))'
+ local -a commands
+ commands=(
+ 'play:play a track'
+ 'stop:stop playing'
+ {open,eject}':eject the CD-ROM tray'
+ 'close:close the CD-ROM tray'
+ 'pause:pause playing'
+ 'resume:resume playing'
+ 'ff:fast forward'
+ 'rew:rewind'
+ 'next:advance one track'
+ 'prev:return to previous track'
+ 'getvol:get current volume settings'
+ 'setvol:set volume settings'
+ 'status:get numerical data regarding the CD status'
+ 'info:short information about the CD'
+ 'tracks:list all tracks on the CD'
+ 'rndplay:play a random track'
+ 'list:list all CDs in a CD-ROM changer'
+ 'slot:changes the current CD in the CD-ROM changer'
+ 'edit:edit information about the disc'
+ 'ext:Extended information about the disc'
+ 'refresh:refresh the information about the CD from a CDDB server'
+ 'device:change the CD-ROM device cdcd will use'
+ 'verbose:toggle verbosity'
+ 'sites:edit the server list'
+ 'access:configure cddb access method'
+ 'help:display a help message'
+ )
+ _describe 'cdcd command' commands
}
if (( CURRENT == 2 )); then
_cdcd_commands
else
- shift words
- (( --CURRENT ))
- case "$words[1]" in
+ case "$words[2]" in
# sub-commands with no args
stop|open|eject|close|pause|resume|next|prev|getvol)
- ;;
+ ;&
status|info|tracks|rndplay|list|slot|refresh)
+ _message 'no more arguments'
;;
# sub-commands with args that cannot be completed
ff|rew|setvol)
@@ -70,30 +61,18 @@
;;
# completeable sub-commands
verbose)
- _arguments \
- ':verbose subcommand:((
- on\:"turn verbosity on"
- off\:"turn verbosity off"))'
+ _wanted subcommand expl 'verbose subcommand' compadd on off
;;
ext)
- _arguments \
- ":ext subcommand:((
- disc\:\"extra information about the disc\"
- $(_cdcd_track_list)))"
+ _values 'ext subcommand' \
+ 'disc[extra information about the disc]' \
+ {1..${${(z)${${(f)"$(cdcd info)"}[3]}}[3]}}
;;
device)
- compadd "$expl[@]" /dev/cd* /dev/cd*/*
+ _wanted device expl 'cdrom device' compadd /dev/cd* /dev/cd*/*
;;
play)
- if (( CURRENT == 2 )); then
- _arguments ":play subcommand:((
- $(_cdcd_track_list_verbose)))"
- else
- shift words
- (( --CURRENT ))
- _arguments ":play subcommand2:((
- $(_cdcd_track_list_verbose)))"
- fi
+ _cdcd_tracks
;;
help)
_cdcd_commands;;
Index: Completion/Unix/Command/_texinfo
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_texinfo,v
retrieving revision 1.2
diff -u -r1.2 _texinfo
--- Completion/Unix/Command/_texinfo 28 May 2002 14:22:39 -0000 1.2
+++ Completion/Unix/Command/_texinfo 9 Aug 2002 15:56:33 -0000
@@ -1,13 +1,12 @@
-#compdef info install-info makeinfo texi2dvi texindex
+#compdef info tkinfo install-info makeinfo texi2dvi texindex
local curcontext="$curcontext" state line ret=1
+local -A opt_args
+local -a info
case $service in
info)
- local -A opt_args
- local -a info
- info=(_call_program info ${words[1]})
-
+ info=( _call_program info ${words[1]} )
_arguments -C -s \
'(: -)--apropos=[look up string in indices]:search string: ' \
'(-f --file)'{\*-d,\*--directory=}'[add directory to infopath]:info dir:_files -/' \
@@ -23,6 +22,8 @@
'--vi-keys[use Vi-like key bindings]' \
'(: -)--version[display version information]' \
'(--apropos -h --help -O --output --version)*::menu items:->item' && ret=0
+
+ info=( $info {(kv)opt_args[(I)(-d|--directory|-f|--file)]} )
;;
install-info)
if _pick_variant debian=Debian gnu --version; then
@@ -128,13 +129,24 @@
'*:texinfo file:_texi'
return
;;
+ tkinfo)
+ _x_arguments -C \
+ '-+'{headers,buttons,balloons,scrollthrough,pagesep,showdir} \
+ '-linklook:menu display:(color font underline)' \
+ '-highlight:link display:(color inverse underline)' \
+ '-searchlook:search match display:(color inverse underline)' \
+ '-iconic' \
+ '-dir:info path:_dir_list' \
+ '-file:info file:_files -g "*.info(|.gz|.bz2)"' \
+ '-node:info node:->item' \
+ '*::menu items:->item' && ret=0
+ info=( _call_program info info ${(kv)opt_args[(I)-file]/-file/-f} )
+ ;;
esac
case $state in
item )
local -a items
-
- info=($info ${(kv)opt_args[(I)(-d|--directory|-f|--file)]})
items=(${${(M)${${(f)"$(${info} --output - ${words[1,CURRENT-1]} 2>/dev/null)"}[1,(r)[[:space:]]#--- The Detailed Node Listing ---[[:space:]]#]}:#\* *~\* Menu:*}:/(#b)\*[[:space:]]##([^:]##):(#B)( \(?##\)[^.]#.|(:|))[[:space:]]#(#b)(*)[[:space:]]#/$match[1]${match[2]:+:}$match[2]})
Index: Completion/Unix/Command/_wget
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_wget,v
retrieving revision 1.5
diff -u -r1.5 _wget
--- Completion/Unix/Command/_wget 11 Dec 2001 17:57:33 -0000 1.5
+++ Completion/Unix/Command/_wget 9 Aug 2002 15:56:33 -0000
@@ -61,7 +61,7 @@
'--exclude-domains=:rejected domains:' \
'--follow-ftp' \
'--follow-tags=:HTML tags:' \
- '(--ignore-tags -G)'{--ignore-tags=,-G+}'[spcify ignored HTML tags]:HTML tags' \
+ '(--ignore-tags -G)'{--ignore-tags=,-G+}'[specify ignored HTML tags]:HTML tags' \
'(--span-hosts -H)'{--span-hosts,-H}'[span hosts]' \
'(--relative -L)'{--relative,-L}'[follow relative links only]' \
'(--include-directories -I)'{--include-directories=,-I+}'[include directories]:allowed directories' \
Index: Completion/Unix/Type/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_urls,v
retrieving revision 1.6
diff -u -r1.6 _urls
--- Completion/Unix/Type/_urls 6 Aug 2002 21:09:37 -0000 1.6
+++ Completion/Unix/Type/_urls 9 Aug 2002 15:56:33 -0000
@@ -1,4 +1,4 @@
-#compdef curl
+#compdef curl -value-,http_proxy,-default-
# Configuration styles used:
#
@@ -82,7 +82,7 @@
fi
;;
file)
- [[ -prefix //localhost/ ]] && compset -P //localhost
+ [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P //(127.0.0.1|localhost)
[[ -prefix /// ]] && compset -P //
if ! compset -P //; then
_tags -C file files
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author