diff options
Diffstat (limited to 'Completion/Zsh')
26 files changed, 359 insertions, 155 deletions
diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey index 81ae69974..df9c8f225 100644 --- a/Completion/Zsh/Command/_bindkey +++ b/Completion/Zsh/Command/_bindkey @@ -27,7 +27,7 @@ _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:_widgets' && ret=0 + '(-l -L -d -A -N -m -p -r -s)*::widget:_widgets' && ret=0 case $state in keymap) diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd index 781fa2af8..4456cf71e 100644 --- a/Completion/Zsh/Command/_compadd +++ b/Completion/Zsh/Command/_compadd @@ -1,47 +1,94 @@ -#compdef compadd +#compdef compadd -P _* -local curcontext="$curcontext" state line ret=1 +local curcontext="$curcontext" ret=1 +local -a state line args typeset -A opt_args -_arguments -C -s -S -A "-*" \ - '-P+[specify prefix]:prefix' \ - '-S+[specify suffix]:suffix' \ - '-p+[specify hidden prefix]:hidden prefix' \ - '-s+[specify hidden suffix]:hidden suffix' \ - '-i+[specify ignored prefix]:ignored prefix' \ - '-I+[specify ignored suffix]:ignored suffix' \ - '(-k)-a[matches are elements of specified arrays]' \ - '(-a)-k[matches are keys of specified associative arrays]' \ - '-d+[specify display strings]:array:_parameters -g "*array*"' \ - '-l[list display strings one per line, not in columns]' \ +args=( + '-P+[specify prefix]:prefix' + '-S+[specify suffix]:suffix' + '-p+[specify hidden prefix]:hidden prefix' + '-s+[specify hidden suffix]:hidden suffix' + '-i+[specify ignored prefix]:ignored prefix' + '-I+[specify ignored suffix]:ignored suffix' '-o[specify order for matches by match string not by display string]:: : _values -s , order "match[order by match not by display string]" "nosort[matches are pre-ordered]" "numeric[order numerically]" - "reverse[order backwards]"' \ - '(-1 -E)-J+[specify match group]:group' \ - '!-V+:group' \ - '(-J -E)-1[remove only consecutive duplicates from group]' \ - '-2[preserve all duplicates]' \ - '(-x)-X[specify explanation]:explanation' \ - '(-X)-x[specify unconditional explanation]:explanation' \ - '-q[make suffix autoremovable]' \ - '-r+[specify character class for suffix autoremoval]:character class' \ - '-R+[specify function for suffix autoremoval]:function:_functions' \ - '-f[mark matches as being files]' \ - '-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 possible completions]' \ - '*-M[specify matching specifications]' \ - '-n[hide matches in completion listing]' \ - '-U[disable internal matching of completion candidates]' \ - '-O+[populate array with matches instead of adding them]:array:_parameters -g "*array*"' \ - '-A+[populate array with expanded matches instead of adding them]:array:_parameters -g "*array*"' \ - '-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"' \ - '-C[add special match that expands to all other matches]' \ - '(-1 -J)-E+[add specified number of display only matches]:number' \ - '*:candidate:->candidates' && ret=0 + "reverse[order backwards]"' + '(-1 -E)-J+[specify match group]:group' + '!-V+:group' + '(-J -E)-1[remove only consecutive duplicates from group]' + '-2[preserve all duplicates]' + '(-x)-X[specify explanation]:explanation' + '(-X)-x[specify unconditional explanation]:explanation' + '-q[make suffix autoremovable]' + '-r+[specify character class for suffix autoremoval]:character class' + '-R+[specify function for suffix autoremoval]:function:_functions' + '-F+[specify array of ignore patterns]:array:_parameters -g "*array*"' + '-Q[disable quoting of possible completions]' + '*-M[specify matching specifications]' + '-n[hide matches in completion listing]' + '-O+[populate array with matches instead of adding them]:array:_parameters -g "*array*"' + '-A+[populate array with expanded matches instead of adding them]:array:_parameters -g "*array*"' + '*-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"' +) + +case $service in + compadd|_(path_|)files) + args+=( + '-W[specify location for matches marked as files]' + ) + ;| + compadd) + args+=( + '(-k)-a[matches are elements of specified arrays]' + '(-a)-k[matches are keys of specified associative arrays]' + '-d+[specify display strings]:array:_parameters -g "*array*"' + '-l[list display strings one per line, not in columns]' + '-f[mark matches as being files]' + '-e[mark matches as being parameters]' + '-C[add special match that expands to all other matches]' + '(-1 -J)-E+[add specified number of display only matches]:number' + '-U[disable internal matching of completion candidates]' + '*:candidate:->candidates' + ) + ;; + _dates) + args=( ${args:#([(][^)]##\)|)-[12noOAD]*} + '-f[specify format for matches]:format:_date_formats' + '-F[select a future rather than past date]' + ) + ;; + _(path_|)files) + args=( ${args:#([(][^)]##\)|)-[OAD]*} + '-g+[specify file glob pattern]:glob pattern' + '-/[complete only directories]' + ) + ;; + _parameters) + args+=( + '-g+[specify pattern to filter parameter type by]:pattern' + ) + ;; + _pids) + args+=( '-m+[pattern to filter process command line by]:pattern' ) + ;; + _process_names) + args+=( + '-a[include all processes]' + '-t[use truncated process names]' + ) + ;; + _sys_calls) + args+=( + '-a[add "all" as an additional match]' + '-n[add "none" as an additional match]' + ) + ;; +esac + +_arguments -C -s -S -A "-*" $args && ret=0 if [[ -n $state ]]; then if (( $+opt_args[-a] )); then diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index 52b82a6e9..da3803039 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -7,10 +7,10 @@ sali_arr=(${(k)saliases}) func_arr=(${(k)functions}) _arguments -C -s -A "-*" -S \ - "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:compadd -k ali_arr" \ - "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ - "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ - "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ - "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k patchars" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global alias:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix alias:compadd -k sali_arr" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern character:compadd -k patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)builtins})" diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index 9410651b7..b62619d89 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -7,10 +7,10 @@ sali_arr=(${(k)dis_saliases}) func_arr=(${(k)dis_functions}) _arguments -C -s -A "-*" -S \ - "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:compadd -k ali_arr" \ - "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ - "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \ - "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ - "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k dis_patchars" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:alias:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k dis_reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix alias:compadd -k sali_arr" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern character:compadd -k dis_patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)dis_builtins})" diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index dd014e7d7..80e570c5d 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -59,7 +59,8 @@ case $service in ;; *) _arguments "$fc_common[@]" "$fc_hist[@]" "$fc_r" \ - '(-A -R -W -a -l -n -d -f -E -i -r -t -D -p -P)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-A -R -W -a -l -n -d -f -E -i -r -t -D -p -P -s)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-A -R -W -a -l -n -d -f -E -i -r -t -D -p -P -e)-s[re-execute command without invoking editor (like -e-)]' \ '(-a -l -L -m -e -r -n -d -f -t -E -i -R -D -A -W -p -P *)-'{\ 'R[read history from file]',\ 'A[append history to file]',\ diff --git a/Completion/Zsh/Command/_sched b/Completion/Zsh/Command/_sched index e8ff5ab87..888708684 100644 --- a/Completion/Zsh/Command/_sched +++ b/Completion/Zsh/Command/_sched @@ -10,7 +10,7 @@ if [[ CURRENT -eq 2 ]]; then else disp=() fi - [[ -z $lines ]] || _wanted jobs expl 'scheduled jobs' \ + [[ -z $lines ]] || _wanted jobs expl 'scheduled job' \ compadd "$disp[@]" - {1..$#lines} return else diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime index 0849f1c85..a57a76ce4 100644 --- a/Completion/Zsh/Command/_strftime +++ b/Completion/Zsh/Command/_strftime @@ -1,14 +1,16 @@ #compdef strftime -local ret=1 expl +local expl two='epoch time' + +if (( words[(I)-r] )); then + two='date string' +fi _arguments -S -A '-*' -s \ + '-n[omit trailing newline]' \ '-q[run quietly]' \ '(3)-r[reverse lookup using strptime]' \ '-s+[assign result to parameter]:param:_parameters' \ '1:format: _date_formats zsh' \ - '2:epoch time (or date string with -r)' \ + "2:$two" \ '3:nanoseconds' \ -&& ret=0 - -return ret diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index ae33ae539..058842378 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -1,6 +1,6 @@ #compdef autoload declare export functions integer float local readonly typeset -local expl state line func i use curcontext="$curcontext" +local expl state state_descr line func i use curcontext="$curcontext" ret=1 local fopts="-f -k -z +k +z" local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x" local -A allargs opt_args @@ -69,8 +69,8 @@ case ${service} in allargs[i]='-i+[specify arithmetic base for output]:: :_guard "[0-9]#" base' \ ;; readonly) use="${use/r/}" ;; - local) use="${use/[fkz]/}" ;& - export) use="${${use//[gkz]/}/x/}" ;; + local) use="${use//[fgkz]/}" ;; + export) use="${use//[fgkxz]/}" ;; esac [[ -z "${words[(r)-*[aA]*]}" ]] || func=p @@ -79,38 +79,38 @@ esac # This function uses whacky features of _arguments which means we # need to look for options to the command beforehand. local onopts offopts -onopts=${(j..)${${words[1,CURRENT-1]:#^-*}##-}} +onopts=${(j..)${${words[1,CURRENT-1]:#^-[^-]*}##-}} offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}} for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} ) done -_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' +_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' && ret=0 if [[ "$state" = vars_eq ]]; then if [[ $func = f ]]; then if (( $+opt_args[+M] || ( $+opt_args[-M] && $+opt_args[-m] ) )); then _wanted functions expl 'math function' compadd -F line - \ - ${${${(f)"$(functions -M)"}##*-M }%% *} + ${${${(f)"$(functions -M)"}##*-M }%% *} && ret=0 elif (( $+opt_args[-M] )); then _arguments ':new math function:_functions' \ ":minimum arguments${(k)opt_args[-s]:+:(1)}" \ ":maximum arguments${(k)opt_args[-s]:+:(1)}" \ - ':shell function:_functions' + ':shell function:_functions' && ret=0 elif (( $+opt_args[-w] )); then - _wanted files expl 'zwc file' _files -g '*.zwc(-.)' + _wanted files expl 'zwc file' _files -g '*.zwc(-.)' && ret=0 elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then - if [[ $PREFIX[1] = [/~] ]]; then + if [[ ${"${(e)PREFIX}"[1]} = [/~] ]] && _files; then # Autoload by absolute path - _files + ret=0 else args=(${^fpath}/*(-.:t)) # Filter out functions already loaded or marked for autoload. local -a funckeys funckeys=(${(k)functions}) args=(${args:|funckeys}) - _wanted functions expl 'shell function' compadd -a args + _wanted functions expl 'shell function' compadd -a args && ret=0 fi elif [[ -n $onopts$offopts ]]; then if [[ -n $offopts ]]; then @@ -127,22 +127,23 @@ if [[ "$state" = vars_eq ]]; then [[ $PREFIX != [_.]* ]]; then args=(${args:#_*}) fi - _wanted functions expl 'shell functions' compadd -a args + _wanted functions expl 'shell function' compadd -a args && ret=0 else - _functions + _functions && ret=0 fi elif [[ "$PREFIX" = *\=* ]]; then compstate[parameter]="${PREFIX%%\=*}" compset -P 1 '*=' - _value + _value && ret=0 elif (( $+opt_args[-a] || $+opt_args[-A] )); then - _parameters -q + _parameters -q && ret=0 elif (( $+opt_args[-T] )); then _arguments \ ':scalar parameter:_parameters -g "*scalar*" -q -S "="' \ ':array parameter:_parameters -g "*array*"' \ - ':separator character' + ':separator character' && ret=0 else - _parameters -q -S '=' + _parameters -q -S '=' && ret=0 fi fi +return ret diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed index 6b68fadf0..f84993d73 100644 --- a/Completion/Zsh/Command/_zed +++ b/Completion/Zsh/Command/_zed @@ -1,10 +1,16 @@ -#compdef zed fned +#compdef zed fned histed case $service in (fned) _arguments -S : ':shell function:_functions';; +(histed) _arguments -S : \ + '1:history file:_files' \ + '2:history size: ';; (zed) _arguments -S : \ - '(- 2):file:_files' \ - '(1):shell function:_functions' \ - '(1)-x+[specify spaces to use for indentation in function expansion]:spaces' \ - '(1)-f[edit function]';; + '(-h 1 3 4)-f[edit function]' \ + '(-h 1 3 4)-x+[specify spaces to use for indentation in function expansion]:spaces' \ + '(-f -x 1 2)-h[edit history]' \ + '(- 2 3 4)1:file:_files' \ + '(3 4)2:shell function:_functions' \ + '3:history file:_files -g "*(D)"' \ + '4:history size';; esac diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle index e01d0a943..0b8ef7a15 100644 --- a/Completion/Zsh/Command/_zle +++ b/Completion/Zsh/Command/_zle @@ -51,11 +51,11 @@ case "$state[1]" in ;; (widget*) _wanted -C "$context[1]" widgets expl "${state_descr[1]:-widget}" _widgets && ret=0 - ;& - (function) - [[ $state[1] != *function ]] || # Handle fall-through + ;| + (*function) _wanted -C "$context[1]" functions expl 'widget shell function' \ - compadd -M 'r:|-=* r:|=*' -k functions && ret=0 + compadd -M 'r:|-=* r:|=*' -k functions && + ret=0 ;; (comp-widget) _wanted -C "$context[1]" widgets expl 'completion widget' \ diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload index 3416d50c6..f3e38c0f6 100644 --- a/Completion/Zsh/Command/_zmodload +++ b/Completion/Zsh/Command/_zmodload @@ -23,7 +23,7 @@ _arguments -n -C -S -s \ '(-e -u)-L[output in the form of calls to zmodload]' \ '(-b -c -d -I -f -F -P -l -m -A -R)-p[autoload module for parameters]' \ '(-u -b -c -d -p -f -A -R)-P[array param for features]:array name:_parameters' \ - '(-)*:params:->params' && ret=0 + '(-)*:param:->params' && ret=0 [[ $state = params ]] || return ret @@ -66,7 +66,7 @@ else while _tags; do _requested builtins expl 'builtin command' \ compadd "$@" -k builtins && ret=0 - _requested loadedmodules expl 'loaded modules' \ + _requested loadedmodules expl 'loaded module' \ compadd -k 'modules[(R)loaded]' && ret=0 _requested files expl 'module file' \ _files -W module_path -g '*.(dll|s[ol]|bundle)(:r)' && ret=0 diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index 7db73c0c0..0c81c2f2e 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -5,9 +5,6 @@ local nm=$compstate[nmatches] taglist patterns contexts MATCH integer MBEGIN MEND typeset -A opt_args styles -_vcs_info_hooks() { - compadd - ${functions[(I)+vi-*]#+vi-} -} # Assoc array of styles; the values give the possible top-level # contexts: # c completion @@ -65,6 +62,7 @@ styles=( ignore-parents c:ignorepar ignored-patterns c: insert-ids c:insert-ids + insert-sections c:insert-sections insert-tab c:bool insert-unambiguous c:insunambig keep-prefix c:keep-prefix @@ -103,6 +101,7 @@ styles=( preserve-prefix c:preserve-prefix range c: recent-dirs-insert c:recent-dirs-insert + recursive-files c: regular c:bool rehash c:bool remote-access c:bool @@ -113,7 +112,7 @@ styles=( show-ambiguity c: show-completer c:bool single-ignored c:single-ignored - sort c:bool + sort c:sort-order special-dirs c:sdirs squeeze-slashes c:bool stop c:stop @@ -145,6 +144,7 @@ styles=( cursor e: edit-buffer e:bool edit-previous e:bool + editor e: insert-kept e: leave-cursor e:bool match e: @@ -218,7 +218,7 @@ taglist=( ) # Be careful with the context arguments here. They like to masquerade. -_arguments -C \ +_arguments -C -A '-*' \ '(: -)-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' \ @@ -229,7 +229,7 @@ _arguments -C \ '(: -)-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' + ':context pattern:->contexts' ':style:->styles' '*:argument:->style-arg' while (( $#state )); do case "$state[1]" in @@ -412,14 +412,15 @@ while (( $#state )); do ;; (function) - _wanted control-function expl 'control function' \ + _wanted control-functions expl 'control function' \ compadd predict-on all-matches ;; (functions) - _wanted comp-widget expl 'completion widget' \ - compadd $suf - all-matches complete-debug complete-tag \ - correct-word expand-word expand-alias-word history-words + _wanted comp-widgets expl 'completion widget' \ + compadd $suf -M 'r:|-=* r:|=*' - all-matches complete-debug complete-tag \ + correct-word expand-word expand-alias-word history-words \ + ${${${(M)${(f)"$(_call_program comp-widgets zle -l)"}:#*-C*}:#_*}/ -C*} ;; (user-host-port) @@ -490,7 +491,7 @@ while (( $#state )); do elif compset -P '*:'; then _message -e tags tag else - _message -e patterns 'glob patterns' + _message -e patterns 'glob pattern' fi ;; @@ -524,6 +525,11 @@ while (( $#state )); do compadd - menu single longer ;; + (insert-sections) + _wanted values expl 'where to insert man page section' \ + compadd - true false prepend suffix + ;; + (fake-files) _message -e fakes 'prefix and names' ;; @@ -571,6 +577,10 @@ while (( $#state )); do _message -e separators 'separator string' ;; + (sort-order) + _wanted sort-orders expl 'sort order' compadd -F line - true false match nosort numeric reverse + ;; + (max-matches-width) _message -e numbers 'maximum display width for matches' ;; @@ -659,7 +669,7 @@ while (( $#state )); do 'p[name of top-most patch (applied-string)]' \ 'u[number of unapplied patches (unapplied-string)]' \ 'n[number of applied patches]' \ - 'c[number of unapplied patches.]' \ + 'c[number of unapplied patches]' \ 'a[number of all patches]' \ 'g[names of active mq guards (hg backend)]' \ 'G[number of active mq guards (hg backend)]' diff --git a/Completion/Zsh/Context/_brace_parameter b/Completion/Zsh/Context/_brace_parameter index 6960cec9b..66be4f7cd 100644 --- a/Completion/Zsh/Context/_brace_parameter +++ b/Completion/Zsh/Context/_brace_parameter @@ -140,8 +140,9 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then flags+=("m:count number of character code points in padding calculation") fi flags+=( - "#:evaluate as numeric expression" + "#:interpret numeric expression as character code" "@:prevent double-quoted joining of arrays" + "*:enable extended globs for pattern" "A:assign as an array parameter" "a:sort in array index order (with O to reverse)" "b:backslash quote pattern characters only" @@ -155,7 +156,8 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then "i:sort case-insensitively" "k:substitute keys of associative arrays" "L:lower case all letters" - "n:sort decimal integers numerically" + "n:sort positive decimal integers numerically" + "-:sort decimal integers numerically" "o:sort in ascending order (lexically if no other sort option)" "O:sort in descending order (lexically if no other sort option)" "P:use parameter value as name of parameter for redirected lookup" diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript index 0c9a89ad5..25cedd193 100644 --- a/Completion/Zsh/Context/_subscript +++ b/Completion/Zsh/Context/_subscript @@ -1,6 +1,8 @@ #compdef -subscript- -local expl ind osuf=']' flags sep +local expl ind osuf flags sep + +[[ $ISUFFIX = *\]* ]] || osuf=\] if [[ "$1" = -q ]]; then compquote osuf @@ -78,7 +80,7 @@ elif compset -P '\('; then );; esac - _values -s '' 'subscript flags' $flags + _values -s '' 'subscript flag' $flags elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then local suf MATCH MBEGIN MEND local -a keys diff --git a/Completion/Zsh/Context/_zcalc_line b/Completion/Zsh/Context/_zcalc_line index 50fb8c17c..ab8e42df9 100644 --- a/Completion/Zsh/Context/_zcalc_line +++ b/Completion/Zsh/Context/_zcalc_line @@ -16,7 +16,7 @@ _zcalc_line_escapes() { "function:define math function (also \:func or \:f)" ) cmds=("\:"${^cmds}) - _describe -t command-escapes "command escapes" cmds -Q + _describe -t command-escapes "command escape" cmds -Q } _zcalc_line() { diff --git a/Completion/Zsh/Function/__arguments b/Completion/Zsh/Function/__arguments new file mode 100644 index 000000000..af7710971 --- /dev/null +++ b/Completion/Zsh/Function/__arguments @@ -0,0 +1,44 @@ +#compdef _arguments + +# Dear reader: This function is called "__arguments" and is the completion +# function for the completion function _arguments. This function, however, is +# not the completion function _arguments. If you're looking for the function +# _arguments, then you've come to the wrong place. +# +# _arguments is a completion utility function. It is called by completion +# functions for command-line tools. +# +# __arguments is a completion function for _arguments. It runs when one does +# `_arguments -<TAB>' at the shell prompt to jog one's memory about _arguments' +# option flags. +# +# _arguments is in documented in the manual. If you were looking for its +# source code, that'd be either in ../../../Completion/Base/Utility/_arguments +# or in ./_arguments, depending on where you're reading this file. +# +# __arguments takes no arguments. + +if (( ${words[(i)--]} < CURRENT )); then + # "Deriving spec forms from the help output" + _arguments : \ + '*-i[specify option name exclude patterns]:option name exclude pattern' \ + '*-s[specify option aliases]:pattern and replacement as "(this that)"' \ + '*:helpspec (pattern\:message\:action)' +else + _arguments -A '-([AMO]*|[0CRSWnsw])' : \ + '!-n[set $NORMARG]' \ + '-s[enable single-letter option stacking (-x -y == -xy)]' \ + '-w[(rarely needed) enable single-letter option stacking with arguments (-x X -y == -xy X)]' \ + '-W[(rarely needed) enable single-letter option stacking with arguments in the same word (-x X -y == -xXy)]' \ + "-C[modify \$curcontext for \`->action' (instead of \$context)]" \ + "-R[when \`->action' matches, return 300]" \ + "-S[honour \`--' as end-of-options guard]" \ + "-A[do not complete options after non-options]:pattern matching unknown options (e.g., '-*')" \ + '-O[pass elements of array variable to function calls in actions]:array variable name:_parameters -g array' \ + "-M[specify matchspec for completing option names and values]:matchspec for completing option names and values [ 'r\\:|[_-]=* r\\:|=*' ]" \ + '-0[have ${(v)opt_args} be NUL-joined rather than colon-escaped and colon-joined]' \ + "--[derive optspecs from \`\${command} --help' output]" \ + '1::optional delimiter:(\:)' \ + '*:spec (e.g., "(-t --to)"*{-t+,--to=}"[specify recipient]\:recipient'\''s address\:_email_addresses)' + # TODO: doesn't support "Specifying Multiple Sets of Arguments" +fi diff --git a/Completion/Zsh/Function/_add-zle-hook-widget b/Completion/Zsh/Function/_add-zle-hook-widget index f108d1868..c0bd77819 100644 --- a/Completion/Zsh/Function/_add-zle-hook-widget +++ b/Completion/Zsh/Function/_add-zle-hook-widget @@ -26,9 +26,12 @@ _add-zle-hook-widget() { local context state state_descr line typeset -A opt_args _arguments -s -w -S : \ - '(-D)-d[remove HOOK from the array]' \ - '(-d)-D[interpret HOOK as pattern to remove from the array]' \ - {-U,-z,-k}"[passed to 'autoload']" \ + "(-d -D -U -z -k)-L[output in form of 'zstyle' commands]" \ + '(-L -D -U -z -k)-d[remove HOOK from the array]' \ + '(-L -d -U -z -k)-D[interpret HOOK as pattern to remove from the array]' \ + '(-L -d -D)-U[suppress alias expansion for functions]' \ + '(-L -d -D -k)-z[mark function for zsh-style autoloading]' \ + '(-L -d -D -z)-k[mark function for ksh-style autoloading]' \ ':hook type:_add-zle-hook-widget_types' \ ':widget:_add-zle-hook-widget_widgets' } diff --git a/Completion/Zsh/Function/_add-zsh-hook b/Completion/Zsh/Function/_add-zsh-hook index e8ae97052..5b1ff0e42 100644 --- a/Completion/Zsh/Function/_add-zsh-hook +++ b/Completion/Zsh/Function/_add-zsh-hook @@ -3,7 +3,7 @@ _add-zsh-hook_hooks() { local expl if (( $+opt_args[-d] )); then - _wanted functions expl "installed hooks" compadd -a - "$line[1]_functions" && return 0 + _wanted functions expl "installed hook" compadd -a - "$line[1]_functions" && return 0 else _functions && return 0 fi @@ -14,9 +14,12 @@ _add-zsh-hook() { local context state state_descr line typeset -A opt_args _arguments -s -w -S : \ - '(-D)-d[remove HOOK from the array]' \ - '(-d)-D[interpret HOOK as pattern to remove from the array]' \ - {-U,-z,-k}"[passed to 'autoload']" \ + "(-d -D -U -z -k)-L[output in form of 'typeset' commands]" \ + '(-L -D -U -z -k)-d[remove HOOK from the array]' \ + '(-L -d -U -z -k)-D[interpret HOOK as pattern to remove from the array]' \ + '(-L -d -D)-U[suppress alias expansion for functions]' \ + '(-L -d -D -k)-z[mark function for zsh-style autoloading]' \ + '(-L -d -D -z)-k[mark function for ksh-style autoloading]' \ ':hook class:(chpwd precmd preexec periodic zshaddhistory zshexit zsh_directory_name)' \ ':hook function:_add-zsh-hook_hooks' } diff --git a/Completion/Zsh/Function/_vcs_info b/Completion/Zsh/Function/_vcs_info new file mode 100644 index 000000000..fdb28de6a --- /dev/null +++ b/Completion/Zsh/Function/_vcs_info @@ -0,0 +1,31 @@ +#compdef vcs_info_hookadd vcs_info_hookdel + +local -a hook_types=( + gen-applied-string + gen-hg-bookmark-string + gen-mqguards-string + gen-unapplied-string + no-vcs + post-backend + post-quilt + pre-addon-quilt + pre-get-data + set-branch-format + set-hgrev-format + set-message + set-patch-format + start-up +) + +local -a specs +case $service in + (vcs_info_hookdel) + specs=( '-a[remove all occurrences, not just the first]' ) + ;; +esac + +# TODO: for vcs_info_hookdel complete only functions installed for that hook +_arguments : \ + $specs \ + ":hook type:($hook_types)" \ + '*:hook function:_vcs_info_hooks' diff --git a/Completion/Zsh/Function/_zargs b/Completion/Zsh/Function/_zargs index f974ab646..94a35e3a5 100644 --- a/Completion/Zsh/Function/_zargs +++ b/Completion/Zsh/Function/_zargs @@ -18,17 +18,17 @@ case $numeofs in #zargs arguments arguments=( '(--eof -e)'{--eof=,-e+}'[change the end-of-input-args string from "--" to eof-str]' - '(--exit, -x)'{--exit,-x}'[exit if the size (see --max-chars) is exceeded]' + '(--exit -x)'{--exit,-x}'[exit if the size (see --max-chars) is exceeded]' '--help[print summary and exit]' - '(--interactive, -p)'{--interactive,-p}'[prompt before executing each command line]' - '(--max-args, -n)'{--max-args=,-n+}'[use at most max-args arguments per command line]' - '(--max-chars, -s)'{--max-chars=,-s+}'[use at most max-chars characters per command line]' - '(--max-lines, -l)'{--max-lines=,-l+}'[use at most max-lines of the input-args per command line]' - '(--max-procs, -P)'{--max-procs=,-P+}'[run up to max-procs command lines in the background at once]' - '(--no-run-if-empty, -r)'{--no-run-if-empty,-r}'[do nothing if there are no input arguments before the eof-str]' - '(--null, -0)'{--null,-0}'[split each input-arg at null bytes, for xargs compatibility]' - '(--replace, -i)'{--replace=,-i}'[substitute replace-str in the initial-args by each initial-arg]' - '(--verbose, -t)'{--verbose,-t}'[print each command line to stderr before executing it]' + '(--interactive -p)'{--interactive,-p}'[prompt before executing each command line]' + '(--max-args -n)'{--max-args=,-n+}'[use at most max-args arguments per command line]' + '(--max-chars -s)'{--max-chars=,-s+}'[use at most max-chars characters per command line]' + '(--max-lines -l)'{--max-lines=,-l+}'[use at most max-lines of the input-args per command line]' + '(--max-procs -P)'{--max-procs=,-P+}'[run up to max-procs command lines in the background at once]' + '(--no-run-if-empty -r)'{--no-run-if-empty,-r}'[do nothing if there are no input arguments before the eof-str]' + '(--null -0)'{--null,-0}'[split each input-arg at null bytes, for xargs compatibility]' + '(--replace -i)'{--replace=,-i}'[substitute replace-str in the initial-args by each initial-arg]' + '(--verbose -t)'{--verbose,-t}'[print each command line to stderr before executing it]' '--version[print the version number of zargs and exit]' ) _arguments -S -s $arguments[@] && ret=0 diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names index cd630b7a4..12cbd69c1 100644 --- a/Completion/Zsh/Type/_command_names +++ b/Completion/Zsh/Type/_command_names @@ -4,7 +4,7 @@ # complete only external commands and executable files. This and a # `-' as the first argument is then removed from the arguments. -local args defs ffilt +local args defs expl ffilt zstyle -t ":completion:${curcontext}:commands" rehash && rehash @@ -16,8 +16,12 @@ defs=( 'commands:external command:_path_commands' ) -[[ -n "$path[(r).]" || $PREFIX = */* ]] && - defs+=( 'executables:executable file:_files -g \*\(-\*\)' ) +if [[ -n "$path[(r).]" || $PREFIX = */* ]]; then + defs+=( 'executables:executable file:_files -g \*\(-\*\)' ) +else + # this is ignored but exists to facilitate the use of the fake style + _description executables expl 'executable file' +fi if [[ "$1" = -e ]]; then shift @@ -41,11 +45,24 @@ fi args=( "$@" ) local -a cmdpath -if zstyle -a ":completion:${curcontext}" command-path cmdpath && - [[ $#cmdpath -gt 0 ]] -then + +zstyle -a ":completion:${curcontext}" command-path cmdpath + +# Using the current PATH doesn't necessarily make sense when completing commands +# to tools like sudo, which might set a different one. A common issue is that +# /**/sbin appear in the PATH used by the tool, but not in the one used by the +# unprivileged user who calls it. To do the right thing in the most common +# cases, we'll simply ensure that the sbin variants always appear here when not +# otherwise overridden (bash-completion's _sudo does something similar) +if (( ! $#cmdpath && $#_comp_priv_prefix )); then + cmdpath=( $path ${path/%\/bin//sbin} ) + cmdpath=( ${(u)^cmdpath}(/-N) ) +fi + +if (( $#cmdpath )); then local -a +h path local -A +h commands - path=( $cmdpath ) + path=( $cmdpath:A ) fi + _alternative -O args "$defs[@]" diff --git a/Completion/Zsh/Type/_globflags b/Completion/Zsh/Type/_globflags index 13ef14c17..d24e8f2a7 100644 --- a/Completion/Zsh/Type/_globflags +++ b/Completion/Zsh/Type/_globflags @@ -5,18 +5,26 @@ local ret=1 local -a flags +local preprefix=$IPREFIX -if compset -P a; then - _message -e number 'errors' - return -elif compset -P q; then +compset -P '([ilIUubBmMcq]|a(|<->))##' +# make sure to not consider anything before the '#' +preprefix=${IPREFIX[$#preprefix,-1]} +if [[ $preprefix = *\#q* ]]; then _globquals return -elif compset -P 'c[0-9]##,'; then - _message -e number 'max repetitions' +elif [[ $preprefix = *q* ]]; then + _message 'q flag has to be specified by itself' return -elif compset -P c; then - _message -e number 'repetitions (min or exact)' +elif [[ $preprefix = *a(|<->) ]]; then + _message -e number 'errors' + if [[ $preprefix = *a ]]; then + return + else + compset -P '<->' + fi +elif [[ $preprefix = *\#c ]]; then + _message -e range 'repetitions (min,max) or (exact)' return fi @@ -35,13 +43,20 @@ flags=( 'm:set reference to entire matched data' 'M:deactivate m flag' ) - +flags=( ${flags:#[$preprefix[(R)\#,-1]]*} ) +if [[ $IPREFIX != *'#' ]]; then + flags=( ${flags:#[se]*} ) +fi _describe -t globflags "glob flag" flags -Q -S ')' && ret=0 flags=( 'a:approximate matching' 'q:introduce glob qualifier' 'c:match repetitions of preceding pattern' ) +flags=( ${flags:#[$preprefix[(R)\#,-1]]*} ) +if [[ $IPREFIX != *'#' ]]; then + flags=( ${flags:#[cq]*} ) +fi _describe -t globflags "glob flag" flags -Q -S '' && ret=0 return ret diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals index 915f97c1c..bc3165eba 100644 --- a/Completion/Zsh/Type/_globquals +++ b/Completion/Zsh/Type/_globquals @@ -127,16 +127,14 @@ while [[ -n $PREFIX ]]; do alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' -a tmatch" ) fi if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then - sdisp=( before exactly since ) - smatch=( - '' + ) if zstyle -t ":completion:${curcontext}:senses" verbose; then zstyle -s ":completion:${curcontext}:senses" list-separator sep || sep=-- default=" [default exactly]" - sdisp=( "- $sep before" "+ $sep since" ) - smatch=( - + ) + sdisp=( "+ $sep before (older files)" "- $sep since (newer files)" ) + smatch=( + - ) else sdisp=( before exactly since ) - smatch=( - '' + ) + smatch=( + '' - ) fi alts+=( "senses:sense${default}:compadd -E 0 -d sdisp -S '' -a smatch" ) fi diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters index eaad3ca9d..b5da45c58 100644 --- a/Completion/Zsh/Type/_parameters +++ b/Completion/Zsh/Type/_parameters @@ -6,18 +6,44 @@ # If you specify a -g option with a pattern, the pattern will be used to # restrict the type of parameters matched. -local expl pattern fakes faked tmp pfilt - if compset -P '*:'; then _history_modifiers p return fi -pattern=(-g \*) +local i pfilt +local -i nm=$compstate[nmatches] +local -a expl pattern=( -g \* ) normal described verbose faked fakes tmp + +zstyle -t ":completion:${curcontext}:parameters" prefix-needed && + [[ $PREFIX != [_.]* ]] && + pfilt='[^_.]' +_description parameters expl parameter zparseopts -D -K -E g:=pattern -fakes=() -faked=() +if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then + described=( + "${(@M)${(@k)parameters[(R)$~pattern[2]~*(hideval|local|special)*]}:#$~pfilt*}" + ) + compadd "$@" "$expl[@]" -D described -a - described + if (( $#described )); then + # Normally, calling typeset without flags would print the values of its + # arguments. However, inside a function, it instead declare its arguments + # as local variables and outputs nothing. Thus, to force it print out + # parameter values, we pass it the -m flag. + verbose=( + ${${${(f@)"$( typeset -m ${(@b)described} )"}/=/:}[@]//'\'/'\\'} + ) + _describe -t parameters parameter verbose "$@" "$expl[@]" + fi + + normal=( + "${(@M)${(@k)parameters[(R)$~pattern[2]~^(*(hideval|special)*)~*local*]}:#$~pfilt*}" + ) +else + normal=( "${(@M)${(@k)parameters[(R)$~pattern[2]~*local*]}:#$~pfilt*}" ) +fi + if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then for i in "$tmp[@]"; do if [[ "$i" = *:* ]]; then @@ -27,13 +53,7 @@ if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then fi done fi +compadd "$@" "$expl[@]" - "$normal[@]" "${(@)fakes:|described}" \ + "${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}" -zstyle -t ":completion:${curcontext}:parameters" prefix-needed && \ - [[ $PREFIX != [_.]* ]] && \ - pfilt='[^_.]' - -_wanted parameters expl parameter \ - compadd "$@" -Q - \ - "${(@M)${(@k)parameters[(R)${pattern[2]}~*local*]}:#${~pfilt}*}" \ - "$fakes[@]" \ - "${(@)${(@M)faked:#${~pattern[2]}}%%:*}" +(( compstate[nmatches] > nm )) diff --git a/Completion/Zsh/Type/_ps1234 b/Completion/Zsh/Type/_ps1234 index cf1982219..0ea2cdda9 100644 --- a/Completion/Zsh/Type/_ps1234 +++ b/Completion/Zsh/Type/_ps1234 @@ -38,7 +38,7 @@ if compset -P '%[FK]'; then ) _description -V ansi-colors expl 'ansi color' - grp="$expl[expl[(i)-V]+1]" + grp="$expl[expl[(i)-J]+1]" print -v ccol -f "($grp)=%s=%s" ${(kv)ansi} _comp_colors+=( $ccol ) compadd "$expl[@]" $suf $pre -k ansi && ret=0 @@ -48,10 +48,10 @@ if compset -P '%[FK]'; then (( cols = $terminfo[colors] - 1 )) (( cols = cols > 255 ? 255 : cols )) _description -V terminal-colors expl 'terminal color' - grp="$expl[expl[(i)-V]+1]" + grp="$expl[expl[(i)-J]+1]" compadd "$expl[@]" $suf $pre {0..$cols} for c in {0..$cols}; do - _comp_colors+=( "($grp)=${c}=${${$(print -P "%F{$c}")#?\[}%m}" ) + _comp_colors+=( "($grp)=${c}=${${${(%):-%F{$c\}}#?\[}%m}" ) done else _message -e terminal-colors "number" diff --git a/Completion/Zsh/Type/_vcs_info_hooks b/Completion/Zsh/Type/_vcs_info_hooks new file mode 100644 index 000000000..bad915000 --- /dev/null +++ b/Completion/Zsh/Type/_vcs_info_hooks @@ -0,0 +1,2 @@ +#autoload +compadd - ${functions[(I)+vi-*]#+vi-} |