summaryrefslogtreecommitdiff
path: root/Completion/Zsh/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Zsh/Command')
-rw-r--r--Completion/Zsh/Command/_bindkey7
-rw-r--r--Completion/Zsh/Command/_compadd2
-rw-r--r--Completion/Zsh/Command/_fc7
-rw-r--r--Completion/Zsh/Command/_precommand2
-rw-r--r--Completion/Zsh/Command/_print42
-rw-r--r--Completion/Zsh/Command/_strftime2
-rw-r--r--Completion/Zsh/Command/_typeset2
-rw-r--r--Completion/Zsh/Command/_vared2
-rw-r--r--Completion/Zsh/Command/_zed8
-rw-r--r--Completion/Zsh/Command/_zle10
-rw-r--r--Completion/Zsh/Command/_zstyle112
11 files changed, 133 insertions, 63 deletions
diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey
index 4c4aeda9d..81ae69974 100644
--- a/Completion/Zsh/Command/_bindkey
+++ b/Completion/Zsh/Command/_bindkey
@@ -27,14 +27,11 @@ _arguments -C -s -S \
'(-l -L -d -D -A -N -m -p -r *)-s[bind each in-string to each out-string]:*:key string' \
'(-e -v -a -M -l -L -d -D -A -N -m -p)-R[interpret in-strings as ranges]' \
'(-l -L -d -A -N -m -p -r -s):in-string' \
- '(-l -L -d -A -N -m -p -r -s)*::widgets:->widget' && ret=0
+ '(-l -L -d -A -N -m -p -r -s)*::widgets:_widgets' && ret=0
case $state in
keymap)
- _wanted -C -M keymaps expl keymap compadd -a keymaps && ret=0
- ;;
- widget)
- _wanted widgets expl widget compadd -M 'r:|-=* r:|=*' -k widgets && ret=0
+ _wanted keymaps expl keymap compadd -a keymaps && ret=0
;;
esac
diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd
index 03fed1854..a7036d027 100644
--- a/Completion/Zsh/Command/_compadd
+++ b/Completion/Zsh/Command/_compadd
@@ -28,7 +28,7 @@ _arguments -C -s -S -A "-*" \
'-e[mark matches as being parameters]' \
'-W[specify location for matches marked as files]' \
'-F+[specify array of ignore patterns]:array:_parameters -g "*array*"' \
- '-Q[disable quoting of matchines]' \
+ '-Q[disable quoting of possible completions]' \
'*-M[specify matching specifications]' \
'-n[hide matches in completion listing]' \
'-U[disable internal matching of completion candidates]' \
diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc
index 68456cc3d..6cc01f32d 100644
--- a/Completion/Zsh/Command/_fc
+++ b/Completion/Zsh/Command/_fc
@@ -1,7 +1,8 @@
#compdef fc history r
local curcontext="$curcontext" state state_descr line ret=1
-local events num cmd sep
+local num cmd sep
+local -a events
typeset -A opt_args
local fc_common fc_hist fc_r
@@ -68,10 +69,10 @@ esac
if [[ -n $state ]]; then
zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
- if [[ -z ${line:#*=*} ]] && compset -P '*='; then
+ if [[ -z ${line:#*=*} ]] && compset -P 1 '*='; then
_message -e replacements 'replacement'
elif [[ -prefix [0-9] ]]; then
- events=( ${(0)"$(printf "%-${#HISTNO}.${#HISTNO}s $sep %s\0" "${(kv)history[@]}")"} )
+ print -v events -f "%-${#HISTNO}.${#HISTNO}s $sep %s" "${(kv)history[@]}"
_wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld events - \
"${events[@]%% *}"
elif [[ -prefix - ]]; then
diff --git a/Completion/Zsh/Command/_precommand b/Completion/Zsh/Command/_precommand
index 53078ca82..f57e668c6 100644
--- a/Completion/Zsh/Command/_precommand
+++ b/Completion/Zsh/Command/_precommand
@@ -1,4 +1,4 @@
-#compdef - nohup eval time rusage noglob nocorrect exec catchsegv aoss hilite
+#compdef - nohup eval time rusage noglob nocorrect exec catchsegv aoss hilite eatmydata setsid
# precommands is made local in _main_complete
precommands+=($words[1])
diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print
index 1eba13e88..0610cd4cf 100644
--- a/Completion/Zsh/Command/_print
+++ b/Completion/Zsh/Command/_print
@@ -1,15 +1,18 @@
#compdef print printf
-local state expl line eflag pflag rest ret=1
+local state expl line eflag pflag rflag rest ret=1
if [[ $service = print ]]; then
# -e flag available only after -R
eflag="${words[1,CURRENT-1][(r)-*R*]:+-e[enable escapes]}"
+ rflag='-r[ignore escape conventions of echo]'
# -p flag only relevant if we have a coprocess
(:>&p) 2>/dev/null &&
pflag='(-s -u -z)-p[print arguments to input of coprocess]'
+ [[ -n ${words[(r)-*f]} ]] && rflag='-r[disable reuse of format string]'
+
if [[ -n ${words[1,CURRENT][(r)-*P*]} ]]; then
rest='*: :->prompt'
else
@@ -17,32 +20,37 @@ if [[ $service = print ]]; then
fi
_arguments -C -s -A "-*" -S \
- '(-f)-r[ignore escape conventions of echo]' \
- '(-r -b -f -m -s -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \
+ '-r[ignore escape conventions of echo]' \
+ '(-r -b -f -m -s -S -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \
'-b[recognise bindkey escape sequences]' \
- '-m[remove arguments matching specified pattern]' \
- '(-r -n -R -l -N -c)-f+[print arguments as for the printf builtin]:format:->printfformat' \
- '(-u -p -z)-s[place results in the history list]' \
+ '-m[remove arguments not matching specified pattern]:pattern' \
+ '(-n -R -l -N -c -S)-f+[print arguments as for the printf builtin]:format:->printfformat' \
+ '(-u -p -z -S)-s[place results in the history list]' \
+ '(-a -f -c -C -i -l -o -O -N -u -p -v -z -s -x -X)-S[place results in the history list, after splitting argument into words]' \
'(-c -f)-n[do not add a newline to the result]' \
- '(-N -c -f)-l[print arguments separated by newlines]' \
- '(-n -l -c -f)-N[print arguments separated and terminated by nulls]' \
- '(-O)-o[sort arguments in ascending order]' \
- '(-o)-O[sort arguments in descending order]' \
- '-i[case-insensitive sorting]' \
- '(-n -l -N -f -s -z)-a[with -c/-C, print arguments across before down]' \
- '(-n -l -N -f -C -s -z)-c[print arguments in columns]' \
- '(-n -l -N -f -c -s -z)-C+[print arguments in specified number of columns]:columns' \
- '(-s -p -z)-u+[specify file descriptor to print arguments to]:file descriptor:_file_descriptors' \
- '(-s -p -u)-z[push arguments onto editing buffer stack]' \
+ '(-N -c -f -S)-l[print arguments separated by newlines]' \
+ '(-n -l -c -f -S)-N[print arguments separated and terminated by nulls]' \
+ '(-O -S)-o[sort arguments in ascending order]' \
+ '(-o -S)-O[sort arguments in descending order]' \
+ '(-S)-i[case-insensitive sorting]' \
+ '(-n -l -N -f -s -S -z)-a[with -c/-C, print arguments across before down]' \
+ '(-n -l -N -f -C -s -S -z)-c[print arguments in columns]' \
+ '(-n -l -N -f -c -s -S -z)-C+[print arguments in specified number of columns]:columns' \
+ '(-s -S -p -z)-u+[specify file descriptor to print arguments to]:file descriptor:_file_descriptors' \
+ '(-s -S -z -p -u)-v[store output in named parameter]:parameter:_parameters' \
+ '(-s -S -p -u)-z[push arguments onto editing buffer stack]' \
'-D[substitute any arguments which are named directories using ~ notation]' \
'-P[perform prompt expansion]' \
- $pflag $eflag $rest && ret=0
+ '(-X -f -a -C -c -s -S -z)-x+[expand leading tabs]:tab width' \
+ '(-x -f -a -C -c -s -S -z)-X+[expand all tabs]:tab width' \
+ $pflag $eflag $rflag $rest && ret=0
elif [[ $service = printf ]]; then
state=printf
fi
if [[ $state = printf ]]; then
_arguments -C -s -S \
+ '-v[store output in named parameter]:parameter:_parameters' \
'1:format:->printfformat' \
'*: :_default' && ret=0
fi
diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime
index 0be7b078d..24ff7dc3e 100644
--- a/Completion/Zsh/Command/_strftime
+++ b/Completion/Zsh/Command/_strftime
@@ -6,7 +6,7 @@ _arguments -S -A '-*' -s \
'-q[run quietly]' \
'-r[reverse lookup using strptime]' \
'-s+[assign result to parameter]:param:_parameters' \
- '1:format: _date_formats' \
+ '1:format: _date_formats zsh' \
'2:epoch time (or date string with -r)' && ret=0
return ret
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index 4e29c23e7..94f63cf7e 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -57,7 +57,7 @@ case ${service} in
;;
integer)
use="Hghilprtux"
- allargs[i]='-i[specify arithmetic base for output]' \
+ allargs[i]='-i+[specify arithmetic base for output]:: :_guard "[0-9]#" base' \
;;
readonly) use="${use/r/}" ;;
local) use="${use/[fkz]/}" ;&
diff --git a/Completion/Zsh/Command/_vared b/Completion/Zsh/Command/_vared
index bb31cc129..aba64880a 100644
--- a/Completion/Zsh/Command/_vared
+++ b/Completion/Zsh/Command/_vared
@@ -6,6 +6,8 @@ _arguments -s -A "-*" \
"-c[create parameter or change type]" \
'-p+[specify left prompt]:prompt' \
'-r+[specify right prompt]:right prompt' \
+ '-i+[specify initialisation widget]:widget:_widgets' \
+ '-f+[specify finish widget]:widget:_widgets' \
'-h[allow access to history]' \
'-e[exit on EOF (^D)]' \
'1:parameter spec:_vars'
diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed
index 184234b02..211dae7df 100644
--- a/Completion/Zsh/Command/_zed
+++ b/Completion/Zsh/Command/_zed
@@ -1,7 +1,9 @@
#compdef zed fned
case $service in
-(fned) _arguments ':shell function:_functions';;
-(zed) _arguments '(-):file:_files' \
- '(:)-f[edit function]:shell function:_functions';;
+(fned) _arguments -S : ':shell function:_functions';;
+(zed) _arguments -S : \
+ '(- 2):file:_files' \
+ '(1):shell function:_functions' \
+ '(1)-f[edit function]';;
esac
diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle
index 3ed373348..e01d0a943 100644
--- a/Completion/Zsh/Command/_zle
+++ b/Completion/Zsh/Command/_zle
@@ -45,23 +45,25 @@ case "$state[1]" in
_arguments \
'(-N)-n[numeric prefix]:number:' \
'(-n)-N[reset numeric prefix]' \
+ '-K[specify temporary keymap]:keymap:compadd -a keymaps' \
+ '-w[set $WIDGET to reflect widget being called]' \
'(-)*:widget arguments: ' && ret=0
;;
(widget*)
- _wanted -C "$context[1]" widgets expl "${state_descr[1]:-widget}" compadd -k widgets && ret=0
+ _wanted -C "$context[1]" widgets expl "${state_descr[1]:-widget}" _widgets && ret=0
;&
(function)
[[ $state[1] != *function ]] || # Handle fall-through
_wanted -C "$context[1]" functions expl 'widget shell function' \
- compadd -k functions && ret=0
+ compadd -M 'r:|-=* r:|=*' -k functions && ret=0
;;
(comp-widget)
_wanted -C "$context[1]" widgets expl 'completion widget' \
- compadd -k "widgets[(R)(*:|)(.|)(${(j(|))compwids})(|:*)]" && ret=0
+ _widgets -g "(*:|)(.|)(${(j(|))compwids})(|:*)" && ret=0
;&
(builtin-comp-widget)
_wanted -C "$context[1]" widgets expl 'builtin completion widget' \
- compadd -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0
+ compadd -M 'r:|-=* r:|=*' -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0
;;
(redisplay)
_arguments -s -S '!-R' \
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 9a6d61891..0e828225e 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -1,25 +1,9 @@
#compdef zstyle
local state context ostate line expl ctop suf
-local nm=$compstate[nmatches] taglist patterns pstyles contexts
+local nm=$compstate[nmatches] taglist patterns contexts
typeset -A opt_args styles
-(( $+functions[_completers] )) ||
-_completers() {
- # option: -p - needs a `_' prefix
- local us
- local -a disp list expl
-
- list=( complete approximate correct match expand list menu oldlist
- ignored prefix history )
- zparseopts -D -K -E 'p=us'
- [[ -n "$us" ]] && us='_'
- zstyle -t ":completion:${curcontext}:completers" prefix-hidden &&
- disp=(-d list)
- _wanted completers expl 'completer' \
- compadd "$@" "$disp[@]" - "$us${^list[@]}"
-}
-
_vcs_info_hooks() {
compadd - ${functions[(I)+vi-*]#+vi-}
}
@@ -173,6 +157,7 @@ styles=(
url-seps e:
whence e:
word-chars e:
+ word-class e:
word-style e:word-style
word-context e:
@@ -231,21 +216,33 @@ taglist=(
email-address ${(k)functions[(I)_email-*]#_}
)
+# Be careful with the context arguments here. They like to masquerade.
_arguments -C \
- '(-)-L[output in form of zstyle commands]' \
- '(: -)-d[delete style definitions]:context pattern:->patterns:*:styles:->pstyles' \
- '(-)-e[value is evaluated when style is looked up]' \
- ':context:->contexts' ':style:->styles' '*:argument:->style-arg'
+ '(: -)-L[output in form of zstyle commands]:pattern for context patterns:->metapatterns:style:->metastyles' \
+ '(: -)-d[delete style definitions]:verbatim context pattern:->patterns:*:styles:->pstyles' \
+ '(: -)-e[value is evaluated when style is looked up]:context pattern:->contexts:style:->styles:*:command:_cmdstring' \
+ '(: -)-g[retrieve style definition]:array parameter:_parameters -g "*array*":verbatim context pattern:->patterns:styles:->pstyles' \
+ '(: -)-s[retrieve style value as string]:context name:->contexts:style:->styles:scalar parameter:_parameters -g "*scalar*":separator: ' \
+ '(: -)-b[retrieve style value as boolean]:context name:->contexts:style:->styles:scalar parameter:_parameters -g "*scalar*"' \
+ '(: -)-a[retrieve style value as array]:context name:->contexts:style:->styles:array parameter:_parameters -g "*array*"' \
+ '(: -)-t[test a style, returning false if it'\''s undefined]:context name:->contexts:style:->styles:*:strings to test presence of: ' \
+ '(: -)-T[test a style, returning true if it'\''s undefined]:context name:->contexts:style:->styles:*:strings to test presence of: ' \
+ '(: -)-m[pattern-match values of a style]:context name:->contexts:style:->styles:pattern: ' \
+ '(-):context pattern:->contexts' '(-):style:->styles' '(-)*:argument:->style-arg'
while (( $#state )); do
case "$state[1]" in
+ # 'contexts' completes either full context names (for -t/-s/-a), or context
+ # patterns (for 'zstyle :foo bar' and -e).
(contexts)
if [[ ! -prefix :*: ]]; then
- _wanted contexts expl context compadd -P : -qS : completion vcs_info zftp
+ _wanted contexts expl "$state_descr" compadd -P : -qS : chpwd completion vcs_info zftp zle
elif compset -P :completion:; then
contexts=( functions _completers cmdorcont argument tag )
elif compset -P :vcs_info:; then
contexts=( vcs-string user-context repo-root-name )
+ elif compset -P :zle:; then
+ _wanted widgets expl widget _widgets -qS :
fi
if (( $#contexts )); then
for ostate in $contexts; do
@@ -263,19 +260,80 @@ while (( $#state )); do
fi
;;
+ # 'patterns' completes context patterns that are set, for -d/-g.
(patterns)
zstyle -g patterns
- _wanted contexts expl 'context pattern' compadd -a patterns
+ _wanted contexts expl "$state_descr" compadd -a patterns
;;
+ # 'metapatterns': patterns that are matched not against contexts, but
+ # against patterns.
+ (metapatterns)
+ zstyle -g patterns
+ patterns=( "${(@b)patterns}" )
+ _wanted contexts expl "$state_descr" compadd -a patterns
+ ;;
+
+ # 'metastyles': styles that are set on context patterns matching the given
+ # metapattern.
+ (metastyles)
+ # Anonymous function to shadow the global $styles assoc
+ () {
+ local metapattern=${(Q)${${opt_args[-L]%:*}//(#m)\\([\\:])/${MATCH[2]}}}
+ local -a metastyles styles
+ local pattern
+ zstyle -g patterns
+ for pattern in "${(@M)patterns:#${~metapattern}}"; do
+ zstyle -g styles $pattern
+ metastyles+=( "${styles[@]}" )
+ done
+ _wanted styles expl "$state_descr" compadd -a metastyles
+ unset pattern
+ unset metastyles
+ }
+ ;;
+
+ # 'pstyles': complete styles that are set for the verbatim context pattern
+ # specified on the command line. (If the user has set no zstyles, this
+ # will complete nothing.)
(pstyles)
- zstyle -g pstyles ${(Q)${(M)opt_args[-d]#*[^\\]:}%:}
+ local -a pstyles
+ local pattern
+ if (( $+opt_args[-d] )); then
+ pattern=${opt_args[-d]}
+ pattern=${pattern%":${(b)PREFIX}"} # remove style
+ pattern=${pattern//(#m)\\([\\:])/${MATCH[2]}} # undo _arguments escaping
+ pattern=${(Q)pattern} # undo command-line escaping (assumes no noglob)
+ zstyle -g pstyles $pattern
+ elif (( $+opt_args[-g] )); then
+ pattern=${opt_args[-g]}
+ pattern=${pattern%":${(b)PREFIX}"} # remove style
+ pattern=${pattern#*:} # remove array name
+ pattern=${pattern//(#m)\\([\\:])/${MATCH[2]}} # undo _arguments escaping
+ pattern=${(Q)pattern} # undo command-line escaping (assumes no noglob)
+ zstyle -g pstyles $pattern
+ fi
_wanted styles expl style compadd -a pstyles
+ unset pattern
+ unset pstyles
;;
+ # 'styles': complete all styles that may be set in the context given on the
+ # command line. This is independent of what styles are set.
(styles)
# Get the top-level context we're completing for, if any.
- case ${(Q)line[1]} in
+ if [[ -n $line[1] ]]; then
+ # zstyle :something <TAB>
+ local the_context=$line[1]
+ else
+ # zstyle -x :something <TAB>
+ local joined_value=${(v)opt_args[(i)(-e|-s|-b|-a|-t|-T|-m)]}
+ local the_context=${(Q)joined_value[0, ${joined_value[(i)[^\\]:]}-2 ]}
+ fi
+ # Note: for 'zstyle :something <TAB>' and for 'zstyle -e :something <TAB>',
+ # $the_context is a context pattern; for -s,-b,-a,-t,-T,-m, it is a context
+ # name. We currently draw no distinction between these two cases.
+ case $the_context in
(:completion:*)
ctop=c
;;
@@ -297,7 +355,7 @@ while (( $#state )); do
;;
(*)
- ctop=cdez
+ ctop=a-z
;;
esac
_wanted styles expl style \
@@ -521,7 +579,7 @@ while (( $#state )); do
;;
(word-style)
- _wanted word-styles expl 'word style' compadd normal shell space
+ _wanted word-styles expl 'word style' compadd {normal,specified,unspecified,shell,whitespace}-subword
;;
(vcs-string)