Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix zstyle context handling
- X-seq: zsh-workers 33485
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: fix zstyle context handling
- Date: Tue, 21 Oct 2014 20:34:40 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1413916482; bh=5y4x5LyN0tofftqS3BGBi8QW5IOAVEiVwqiLmcuq4CU=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=y2KrxzAWB3z/PNxyqXj/98ja1QENFr8M7s+AWUZ8o9zkFRGtR05/YgytHKKaz8dLjrt1rVErNBFNd+5laf+bZ99Cl9+AJWLnHAv0zuzlF2+UgQhxTbQXmJypXTaSH5G3mBNb7SdwBt7BtmIap/XrmFGgC1M2TS61OHOtU1zK208=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
As I mentioned last week, bad handling of zstyle contexts with
_arguments/_values is not uncommon in our completion functions. I had
made a note of offending functions at the time and this patch fixes many
cases.
Oliver
diff --git a/Completion/BSD/Command/_portsnap b/Completion/BSD/Command/_portsnap
index db71fbc..0803a84 100644
--- a/Completion/BSD/Command/_portsnap
+++ b/Completion/BSD/Command/_portsnap
@@ -1,6 +1,6 @@
#compdef portsnap
-local context state line
+local curcontext="$curcontext" state line
typeset -A opt_args
flags=(
diff --git a/Completion/Darwin/Command/_defaults b/Completion/Darwin/Command/_defaults
index 7818e03..ca5d87e 100644
--- a/Completion/Darwin/Command/_defaults
+++ b/Completion/Darwin/Command/_defaults
@@ -25,8 +25,9 @@ _defaults(){
_1st_arguments=( read read-type write rename delete domains find help )
local curcontext="$curcontext" state line expl
+ typeset -A opt_args
- _arguments -A '-*' \
+ _arguments -C -A '-*' \
'(-currentHost)-host:host:_hosts' \
'(-host)-currentHost' \
'*::command:->subcmd' && return 0
diff --git a/Completion/Darwin/Command/_fink b/Completion/Darwin/Command/_fink
index 55c9e8d..a7e2ec0 100644
--- a/Completion/Darwin/Command/_fink
+++ b/Completion/Darwin/Command/_fink
@@ -86,7 +86,7 @@ _fink(){
'cleanup:removes obsolete package files'
)
- local context state line expl
+ local curcontext="$curcontext" state line expl
local -A opt_args
_arguments \
@@ -161,6 +161,7 @@ _fink(){
#scanpackages)
#checksums)
#cleanup)
+ *) _default ;;
esac
}
diff --git a/Completion/Debian/Command/_dchroot b/Completion/Debian/Command/_dchroot
index 43a797d..c26e569 100644
--- a/Completion/Debian/Command/_dchroot
+++ b/Completion/Debian/Command/_dchroot
@@ -20,8 +20,8 @@ _arguments -S \
'*::arguments: _normal' && return 0
case "$state" in
- (chroot)
- _wanted tag expl 'chroot' \
- compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}}
- ;;
+ chroot)
+ _wanted -C $context chroots expl 'chroot' \
+ compadd ${(os:,:)${${${"$(_call_program chroots dchroot -l )"#*: }// /}//[[\]]/,}}
+ ;;
esac
diff --git a/Completion/Debian/Command/_dchroot-dsa b/Completion/Debian/Command/_dchroot-dsa
index bed4bcf..d4668b5 100644
--- a/Completion/Debian/Command/_dchroot-dsa
+++ b/Completion/Debian/Command/_dchroot-dsa
@@ -19,8 +19,8 @@ _arguments -S \
'*::arguments: _normal' && return 0
case "$state" in
- (chroot)
- _wanted tag expl 'chroot' \
- compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}}
- ;;
+ chroot)
+ _wanted -C $context chroots expl 'chroot' \
+ compadd ${(os:,:)${${${"$(_call_program chroots dchroot -l )"#*: }// /}//[[\]]/,}}
+ ;;
esac
diff --git a/Completion/Debian/Command/_make-kpkg b/Completion/Debian/Command/_make-kpkg
index c079d9a..55adf88 100644
--- a/Completion/Debian/Command/_make-kpkg
+++ b/Completion/Debian/Command/_make-kpkg
@@ -1,9 +1,9 @@
#compdef make-kpkg
-local context state line
+local curcontext="$curcontext" state line
typeset -A opt_args
-_arguments \
+_arguments -C \
'--help[display help message]' \
'--revision[change Debian revision number]:number:' \
'--append-to-version[specify additional kernel sub-version]:suffix:' \
@@ -45,7 +45,7 @@ _arguments \
configure\:"configure the kernel" \
debian\:"creates the debian/ directory" \
libc-kheaders\:"create the kernel headers package needed by libc" \
- ))' && return 0
+ ))' && return
case "$state" in
(addedmodules)
diff --git a/Completion/Debian/Command/_update-alternatives b/Completion/Debian/Command/_update-alternatives
index ccf5084..31128dd 100644
--- a/Completion/Debian/Command/_update-alternatives
+++ b/Completion/Debian/Command/_update-alternatives
@@ -1,6 +1,6 @@
#compdef update-alternatives
-local curcontext="$curcontext" context state line alterdir
+local curcontext="$curcontext" state line alterdir ret
if [[ -d /var/lib/dpkg/alternatives ]]; then
alterdir=/var/lib/dpkg/alternatives
diff --git a/Completion/Debian/Command/_vim-addons b/Completion/Debian/Command/_vim-addons
index dbd0ee3..ec8a99e 100644
--- a/Completion/Debian/Command/_vim-addons
+++ b/Completion/Debian/Command/_vim-addons
@@ -1,47 +1,48 @@
#compdef vim-addons
-local state line cmds ret=1
+local context state line expl ret=1
typeset -A opt_args
-_arguments -C \
- {-q,--query}'[be quiet and make the output more parseable]' \
- {-r,--registry-dir}'[set the registry directory]' \
- {-s,--source-dir}'[set addon source directory]' \
- {-t,--target-dir}'[set addon target directory]' \
- {-v,--verbose}'[increase verbosity]' \
- {-y,--system-dir}'[set system-wide target directory]' \
- {-h,--help}'[help]' \
- {-w,--system-wide}'[set target directory to the system-wide one (overrides -t)]' \
- '1: :->cmds' \
- '*: :->args' && ret=0
+_arguments \
+ '(-q --query)'{-q,--query}'[be quiet and make the output more parseable]' \
+ '(-r --registry-dir)'{-r,--registry-dir}'[set the registry directory]' \
+ '(-s --source-dir)'{-s,--source-dir}'[set addon source directory]' \
+ '(-t --target-dir -w --system-wide)'{-t,--target-dir}'[set addon target directory]' \
+ '(-v --verbose -z --silent)'{-v,--verbose}'[increase verbosity]' \
+ '(y --system-dir)'{-y,--system-dir}'[set system-wide target directory]' \
+ '(-)'{-h,--help}'[show help information]' \
+ '(-w --system-wide -t --target-dir)'{-w,--system-wide}'[use system-wide target directory]' \
+ '(-z --silent -v --verbose)'{-z,--silent}'[supress most output]' \
+ '1:commands:((
+ install\:install\ specified\ addons
+ remove\:remove\ specified\ addons
+ list\:list\ available\ addons\ in\ registry
+ status\:list\ status\ of\ addons
+ disable\:disable\ specified\ addons
+ enable\:undo\ effects\ of\ previous\ disable
+ files\:list\ files\ composing\ the\ specified\ addon
+ show\:display\ detailed\ information\ on\ specified\ addon
+ ))' \
+ '*: :->args' && ret=0
case $state in
- cmds)
- cmds=(
- 'install:install the specified addon'
- 'remove:remove the specified addon'
- 'list:list available addons in registry'
- 'status:list the status of addons'
- 'disable:disable the specified addons'
- 'amend:under the effects of the previous disable'
- 'files:list the files composing the specified addon'
- 'show:display detailed information about the specified addon'
- )
- _describe -t commands 'vim-addons command' cmds && ret=0
- ;;
args)
case $line[1] in
install)
- _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 == "removed" { print $1 }') && ret=0
+ _wanted -C $context addons expl 'addon' compadd - \
+ ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*removed}%$'\t'*} && ret=0
;;
- amend)
- _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 == "disabled" { print $1 }') && ret=0
+ enable)
+ _wanted -C $context addons expl 'addon' compadd - \
+ ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*disabled}%$'\t'*} && ret=0
;;
remove)
- _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 ~ /disabled|installed/ { print $1 }') && ret=0
+ _wanted -C $context addons expl 'addon' compadd - \
+ ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*(disabled|installed)}%$'\t'*} && ret=0
;;
- files|status|disable|show)
- _wanted addon expl 'addon' compadd $(command vim-addons list) && ret=0
+ *)
+ _wanted -C $context addons expl 'addon' compadd - \
+ $(_call_program addons vim-addons list) && ret=0
;;
esac
;;
diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du
index 9ae6e9c..8b053ba 100644
--- a/Completion/Unix/Command/_du
+++ b/Completion/Unix/Command/_du
@@ -1,7 +1,7 @@
#compdef du
if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then
- local ret=1
+ local context state line expl ret=1
_arguments -s \
'(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \
@@ -24,7 +24,7 @@ if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then
\*{-X+,--exclude-from=}'[exclude files matching any pattern in file]:file:_files' \
'*--exclude=[exclude files matching pattern]:pattern' \
'(-s --summarize)--max-depth=[maximum levels to recurse]:levels' \
- '--files0-from=[use NUL-terminated list of files from file]:file' \
+ '--files0-from=[use NUL-terminated list of files from file]:file:_files' \
'--time-style=[show times using given style, +FORMAT for strftime formatted args]:style:->timestyle' \
'--time=-[show time of last modification of any file in the directory]:property:->time' \
'(* -)--help[display help information]' \
@@ -35,14 +35,14 @@ if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then
(time)
local -a property
property=(atime access use ctime status)
- _wanted property expl property compadd -a property && ret=0
- ;;
+ _wanted -C $context property expl property compadd -a property && ret=0
+ ;;
(timestyle)
local -a style desc
style=(full-iso long-iso iso +)
desc=('full-iso' 'long-iso' 'iso' '+FORMAT like `date'\''')
- _wanted -V style expl style compadd -d desc -a style && ret=0
- ;;
+ _wanted -C $context -V style expl style compadd -d desc -a style && ret=0
+ ;;
esac
return ret
diff --git a/Completion/Unix/Command/_ecasound b/Completion/Unix/Command/_ecasound
index e31b072..7ad08d0 100644
--- a/Completion/Unix/Command/_ecasound
+++ b/Completion/Unix/Command/_ecasound
@@ -1,9 +1,9 @@
#compdef ecasound
-local curcontext="$curcontext" state line expl
+local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args
-_arguments \
+_arguments -C \
'-c[start in interactive mode]' \
'(-q)-d\:-[debug level]:debug level' \
'-D[print all debug information to stderr]' \
@@ -53,7 +53,7 @@ _arguments \
'*-eli\:-[LADSPA Plugin]: :->el' \
'*-gc\:-[time crop gate]: :->gc' \
'*-ge\:-[threshold gate]: :->ge' \
- && return 0
+ ':input source:->io' && ret=0
case $state in
filters)
@@ -82,12 +82,12 @@ case $state in
'r[reverb effect]: :->etr'
;;
emod)
- _values -S : 'envelopme modulation' \
+ _values -S : 'envelope modulation' \
'b[pulse gate]: :->eemb' \
'p[pulse gate (hz)]: :->eemp' \
't[tremolo effect]: :->eemt'
;;
-esac
+esac && ret=0
case $state in
b)
@@ -173,12 +173,12 @@ case $state in
typeset -A msgs
local str
msgs=(
- eac 'amplification value (percent):channel'
- eaw 'amplification value (percent):channel:max-clipped-samples'
- ec 'compression rate (decibels):threshold (0.0-1.0)'
- eca 'peak-level:release-time (seconds):fast compression rate (0.0-1.0):compression rate'
- enm 'threshold-level:pre-hold-time (msec):attack-time (msec):post-hold-time (msec):release-time (msec)'
- ezx 'left DC fix value:right CD fix value'
+ eac 'amplification value (percent):channel'
+ eaw 'amplification value (percent):channel:max-clipped-samples'
+ ec 'compression rate (decibels):threshold (0.0-1.0)'
+ eca 'peak-level:release-time (seconds):fast compression rate (0.0-1.0):compression rate'
+ enm 'threshold-level:pre-hold-time (msec):attack-time (msec):post-hold-time (msec):release-time (msec)'
+ ezx 'left DC fix value:right CD fix value'
eemb 'pulse frequency (beats per minute):on time (msec)'
eemp 'pulse frequency (hz):on time (percent)'
eemt 'tremolo speed (beats per second):depth (percent)'
@@ -206,5 +206,7 @@ case $state in
str="${str#*:}"
done
_message "${str%%:*}"
- ;;
-esac
+ ;;
+esac && ret=0
+
+return ret
diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg
index 6a4ba23..2724f1e 100644
--- a/Completion/Unix/Command/_ffmpeg
+++ b/Completion/Unix/Command/_ffmpeg
@@ -1,6 +1,6 @@
#compdef ffmpeg
-local context state line expl
+local curcontext="$curcontext" state line expl
typeset -A opt_args
(( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() {
@@ -33,14 +33,10 @@ typeset -A opt_args
_wanted ffmpeg-formats expl 'force format' compadd -a formats
}
-(( $+functions[_ffmpeg_list_pix_fmts] )) || _ffmpeg_list_pix_fmts() {
- echo - ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
-}
-
(( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() {
local pix_fmts
- pix_fmts=($(_ffmpeg_list_pix_fmts))
- _wanted ffmpeg-pix-fmts expl 'set pixel format' compadd -a pix_fmts
+ _wanted ffmpeg-pix-fmts expl 'pixel format' compadd "$@" - \
+ ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
}
(( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() {
@@ -82,7 +78,7 @@ typeset -A _ffmpeg_flags
_ffmpeg_flag_options && ret=0
fi
- return $ret
+ return ret
}
(( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() {
@@ -150,7 +146,7 @@ local -a _ffmpeg_argspecs
elif [[ $lastopt == -pix_fmt ]]; then
lastopt_takesargs=0
lastopt="*$lastopt"
- lastopt+=": :_ffmpeg_pix_fmts"
+ lastopt+=":set pixel format:_ffmpeg_pix_fmts"
elif [[ $example == bitstream_filter ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_bsfs"
@@ -175,17 +171,17 @@ local -a _ffmpeg_argspecs
[[ -n $lastopt ]] && _ffmpeg_register_lastopt_values
}
-_arguments -S \
+_arguments -C -S \
"${_ffmpeg_argspecs[@]}" \
'*:output file:_files' \
- && return 0
+ && return
[[ "$state" == "vfilters" ]] &&
_values -s , -S = 'video filters' \
'aspect:set aspect ratio (rational number X\:Y or decimal number):' \
'crop:crop input video (x\:y\:width\:height):' \
- 'format: :->format' \
- 'noformat: :->noformat' \
+ 'format: :_sequence -s : _ffmpeg_pix_fmts' \
+ 'noformat: :_sequence -s : _ffmpeg_pix_fmts' \
'null' \
'pad:add pads to the input image (width\:height\:x\:y\:color_string):' \
'pixelaspect:set pixel aspect ratio (rational number X\:Y or decimal number):' \
@@ -196,15 +192,9 @@ _arguments -S \
'buffer' \
'nullsrc' \
'nullsink' \
- && return 0
-
-[[ "$state" == "format" ]] &&
- _values -s : -S = 'convert input video to one of the specified pixel formats' $(_ffmpeg_list_pix_fmts) && return 0
-
-[[ "$state" == "noformat" ]] &&
- _values -s : -S = 'disable specified pixel formats by force' $(_ffmpeg_list_pix_fmts) && return 0
+ && return
[[ -n $state && -n $_ffmpeg_flags[$state] ]] &&
- _ffmpeg_flags $state && return 0
+ _ffmpeg_flags $state && return
return 1
diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln
index 89b7177..12baf76 100644
--- a/Completion/Unix/Command/_ln
+++ b/Completion/Unix/Command/_ln
@@ -3,10 +3,17 @@
local curcontext="$curcontext" state line ret=1
local -A opt_args
-local -a args
+local -a args bsd
args=(
'-f[remove existing destination files]'
- '-s[create symbolic links instead of hard links]')
+ '-s[create symbolic links instead of hard links]'
+)
+bsd=(
+ '-F[remove existing destination directories]'
+ {-h,-n}'[do not dereference destination]'
+ '-i[prompt before removing destination files]'
+ '-v[print name of each linked file]'
+)
local -a opts
@@ -44,14 +51,16 @@ elif (( ${+builtins[ln]} )); then
{-h,-n}'[do not dereference destination]'
'-i[prompt before removing destination files]')
elif [[ $OSTYPE == darwin* ]]; then
- args+=(
- '-F[remove existing destination directories]'
- {-h,-n}'[do not dereference destination]'
- '-i[prompt before removing destination files]'
- '-v[print name of each linked file]')
+ args+=( $bsd )
+elif [[ $OSTYPE == freebsd* ]]; then
+ args+=( $bsd
+ '(-L)-P[create hard links directly to symbolic links]'
+ '(-P)-L[create hard links to symbolic link references]'
+ "-w[warn if source of a symbolic link doesn't currently exist]"
+ )
fi
-_arguments -s $opts \
+_arguments -C -s $opts \
$args \
':link target:_files' \
'*:: :->files' && ret=0
diff --git a/Completion/Unix/Command/_mail b/Completion/Unix/Command/_mail
index 90c7535..d618cf3 100644
--- a/Completion/Unix/Command/_mail
+++ b/Completion/Unix/Command/_mail
@@ -1,9 +1,9 @@
#compdef mail mailx=mail Mail=mail mush zmail nail=mail
_arguments -s \
- '(-f -u)*-b[specify a BCC recipient]:BCC recipient:->userhost' \
- '(-f -u)*-c[specify a CC recipient]:CC recipient:->userhost' \
+ '(-f -u)*-b[specify a BCC recipient]:BCC recipient:_email_addresses -n $service' \
+ '(-f -u)*-c[specify a CC recipient]:CC recipient:_email_addresses -n $service' \
'(-b -c -u -s *)-f+[specify mail folder]:mailbox:_mailboxes' \
- '(-f -u)-s+[specify a subject]:subject:' \
+ '(-f -u)-s+[specify a subject]:subject' \
"(-b -c -f -s *)-u+[read specified user's mail]:user:_users" \
"(-f -u)*:recipient:_email_addresses -n $service"
diff --git a/Completion/Unix/Command/_mosh b/Completion/Unix/Command/_mosh
index dacbd10..c19f6eb 100644
--- a/Completion/Unix/Command/_mosh
+++ b/Completion/Unix/Command/_mosh
@@ -1,9 +1,8 @@
#compdef mosh
local curcontext="$curcontext" state line
-local -a suf
-_arguments \
+_arguments -C \
'(-)--help[display help information]' \
'(-)--version[display version information]' \
"--no-init[don't set terminal init string]" \
diff --git a/Completion/Unix/Command/_mysqldiff b/Completion/Unix/Command/_mysqldiff
index 094694d..4b46c86 100644
--- a/Completion/Unix/Command/_mysqldiff
+++ b/Completion/Unix/Command/_mysqldiff
@@ -1,8 +1,5 @@
#compdef mysqldiff
-local curcontext="$curcontext" state line expl
-typeset -A opt_args
-
_mysqldiff () {
_arguments -s \
{-h{,1,2},--host{,1,2}=}':server hostname:_mysql_hosts' \
diff --git a/Completion/Unix/Command/_od b/Completion/Unix/Command/_od
index d542597..36a9b7d 100644
--- a/Completion/Unix/Command/_od
+++ b/Completion/Unix/Command/_od
@@ -1,6 +1,6 @@
#compdef od
-local context state state_descr line args ret=1
+local curcontext="$curcontext" state state_descr line args ret=1
local -A opt_args
args=(
@@ -49,7 +49,7 @@ else
esac
fi
-_arguments -s -S : "$args[@]" && return 0
+_arguments -C -s -S : "$args[@]" && return 0
case "$state" in
(format)
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index 95d0ea2..3af55a3 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -1,6 +1,6 @@
#compdef pgrep pkill
-local context state line ret=1 expl
+local curcontext="$curcontext" state line ret=1 expl
typeset -A opt_args
typeset -a arguments
@@ -66,7 +66,7 @@ esac
arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*}
'*:process name:->pname')
-_arguments -s -w $arguments && ret=0
+_arguments -C -s -w $arguments && ret=0
case $state in
(tty)
diff --git a/Completion/Unix/Command/_pydoc b/Completion/Unix/Command/_pydoc
index 92a01a7..f85ab0c 100644
--- a/Completion/Unix/Command/_pydoc
+++ b/Completion/Unix/Command/_pydoc
@@ -1,16 +1,19 @@
#compdef pydoc
-local context state line
+local context state line ret=1
typeset -A opt_args
_arguments \
- '-k[keyword]:keyword:' \
- '-p[port]:port:_ports' \
- '-g[gui]' \
- '-w[write out HTML]:file or dir:_files' \
- ':keyword, topic, module, package, or dotted reference:->lookup' && return 0
+ '(-)-k[search keyword]:keyword' \
+ '(- *)-p[start web server on specified port]:port number' \
+ '(- *)-g[start gui]' \
+ '(-)-w[write out HTML]:file or dir:_files' \
+ '(- *)-h[show help information]' \
+ '*: :->lookup' && ret=0
-_alternative \
- 'keywords:keyword:compadd ${=${${(f)"$(pydoc keywords)"}[2,-1]}}' \
- 'topics:topic:compadd ${=${${(f)"$(pydoc topics)"}[2,-1]}}' \
- 'modules:module:'
+[[ -n $state ]] && _alternative -C $context \
+ 'keywords:keyword:compadd ${=${${(f)"$(_call_program keywords pydoc keywords)"}[2,-1]}}' \
+ 'topics:topic:compadd ${=${${(f)"$(_call_program topics pydoc topics)"}[2,-1]}}' \
+ 'modules:module:' && ret=0
+
+return ret
diff --git a/Completion/Unix/Command/_ri b/Completion/Unix/Command/_ri
index feb10ec..070f46a 100644
--- a/Completion/Unix/Command/_ri
+++ b/Completion/Unix/Command/_ri
@@ -3,7 +3,7 @@
local curcontext="$curcontext" state line ret=1
typeset -A opt_args
-_arguments \
+_arguments -C \
'(- *)'{-h,--help}'[print help information and exit]' \
'(- *)'{-v,--version}'[display the version of ri]' \
'*'{-d,--doc-dir}'[directory to search for documentation]:ri doc directory:_files -/' \
@@ -42,8 +42,6 @@ if [[ "$state" = ri-name ]]; then
if compset -P '?*(::|\#|.)'; then
class_dir=${IPREFIX//(::|\#|.)/\/}
- #else
- # :
fi
esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})}
diff --git a/Completion/Unix/Command/_su b/Completion/Unix/Command/_su
index 6d0f2cd..989aa96 100644
--- a/Completion/Unix/Command/_su
+++ b/Completion/Unix/Command/_su
@@ -1,9 +1,9 @@
#compdef su
local -A opt_args
-local -a args state context
+local -a args context state line expl
local shell=${words[(i)(-s|--shell=*)]} first='1:user name:_users'
-local usr=root line
+local usr=root
if _pick_variant gnu="Free Software Foundation" unix --version; then
args=(
@@ -20,10 +20,20 @@ if _pick_variant gnu="Free Software Foundation" unix --version; then
)
else
args=(
- '-c[pass command to shell]:command string:->command'
'-l[use a login shell]'
'-s[run the specified shell]:shell:->shell'
)
+ case $OSTYPE in
+ freebsd*)
+ args=(
+ '-c[use settings from specified login class]:class'
+ '-f[if the invoked shell is csh, prevent it from reading ,cshrc]'
+ '-l[use a login shell]'
+ '-m[do not reset environment]'
+ '-s[set the MAC label]'
+ )
+ *) args+=( '-c[pass command to shell]:command string:->command' ) ;;
+ esac
fi
if [[ $#words -ge 2 && $words[2] != -* && CURRENT -ne 2 ]]; then
@@ -50,11 +60,11 @@ case $state in
return
;;
(shell)
- compadd ${(f)^"$(</etc/shells)"}(N)
+ _wanted -C $context shells expl shell compadd ${(f)^"$(</etc/shells)"}(N)
return
;;
(rest)
- if [[ -z $shell || $shell = */nologin ]]; then
+ if [[ -z $shell || $shell = */(nologin|false) ]]; then
_arguments "-s[run the specified shell, $usr has no shell]" ||
_message "-s option required, $usr has no shell"
compstate[insert]=
diff --git a/Completion/Zsh/Command/_tcpsys b/Completion/Zsh/Command/_tcpsys
index dcc6f6c..1240ffb 100644
--- a/Completion/Zsh/Command/_tcpsys
+++ b/Completion/Zsh/Command/_tcpsys
@@ -1,16 +1,16 @@
#compdef tcp_open
-local context line expl nm=$compstate[nmatches]
-local -a state argargs sesslist
+local curcontext="$curcontext" state line expl
local -A opt_args
+local -a argargs sesslist
case $service in
(tcp_open)
argargs=(
'(-a -f -l)-s[open session(s)]'
'(-a -f -s)-l[open list of sessions]'
- '(-f -s -l)-a[open session for accept on fd]:fd:->fd'
- '(-a -s -l)-f[open session for accept on fd]:fd:->fd'
+ '(-f -s -l)-a[open session for accept on fd]:fd'
+ '(-a -s -l)-f[open session for accept on fd]:fd'
'-q[quiet mode]'
'-z[no zle handler]'
)
@@ -19,7 +19,7 @@ case $service in
elif [[ -n $words[(R)-(l|s)*] ]]; then
argargs+=('*:session:->session')
else
- argargs+=(':host:->host' ':port:->port' '*:session:->session')
+ argargs+=(':host:_hosts' ':port:_ports' '*:session:->session')
fi
_arguments -C $argargs
;;
@@ -27,14 +27,6 @@ esac
while (( $#state )); do
case "$state[1]" in
- (host)
- _hosts
- ;;
-
- (port)
- _ports
- ;;
-
(sessionlist)
compset -P '*,'
;&
diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr
index 1924bb2..7356417 100644
--- a/Completion/Zsh/Command/_zattr
+++ b/Completion/Zsh/Command/_zattr
@@ -1,7 +1,6 @@
#compdef zgetattr zsetattr zdelattr zlistattr
-local state line expl ret=1 REPLY
-local -a args privs
+local context state line expl ret=1 REPLY
case $service in
zgetattr)
@@ -30,5 +29,7 @@ esac && ret=0
if [[ $state = attrs ]]; then
zlistattr ${~${(Q)line[1]}} REPLY 2> /dev/null
- _wanted attrs expl 'attribute' compadd $REPLY
+ _wanted -C "$context[1]" attrs expl 'attribute' compadd -a REPLY && ret=0
fi
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author