mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-01 21:51:40 +02:00
48378: complete compadd options for other completion functions
This commit is contained in:
parent
f3caff1536
commit
eaff11c748
2 changed files with 87 additions and 37 deletions
|
@ -1,5 +1,8 @@
|
||||||
2021-04-09 Oliver Kiddle <opk@zsh.org>
|
2021-04-09 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 48378: Completion/Zsh/Command/_compadd: complete compadd
|
||||||
|
options for other completion functions
|
||||||
|
|
||||||
* 48437: Completion/Unix/Command/_gdb: fix pid completion when
|
* 48437: Completion/Unix/Command/_gdb: fix pid completion when
|
||||||
cursor is in the middle of the line
|
cursor is in the middle of the line
|
||||||
|
|
||||||
|
|
|
@ -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
|
typeset -A opt_args
|
||||||
|
|
||||||
_arguments -C -s -S -A "-*" \
|
args=(
|
||||||
'-P+[specify prefix]:prefix' \
|
'-P+[specify prefix]:prefix'
|
||||||
'-S+[specify suffix]:suffix' \
|
'-S+[specify suffix]:suffix'
|
||||||
'-p+[specify hidden prefix]:hidden prefix' \
|
'-p+[specify hidden prefix]:hidden prefix'
|
||||||
'-s+[specify hidden suffix]:hidden suffix' \
|
'-s+[specify hidden suffix]:hidden suffix'
|
||||||
'-i+[specify ignored prefix]:ignored prefix' \
|
'-i+[specify ignored prefix]:ignored prefix'
|
||||||
'-I+[specify ignored suffix]:ignored suffix' \
|
'-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]' \
|
|
||||||
'-o[specify order for matches by match string not by display string]:: : _values -s , order
|
'-o[specify order for matches by match string not by display string]:: : _values -s , order
|
||||||
"match[order by match not by display string]"
|
"match[order by match not by display string]"
|
||||||
"nosort[matches are pre-ordered]"
|
"nosort[matches are pre-ordered]"
|
||||||
"numeric[order numerically]"
|
"numeric[order numerically]"
|
||||||
"reverse[order backwards]"' \
|
"reverse[order backwards]"'
|
||||||
'(-1 -E)-J+[specify match group]:group' \
|
'(-1 -E)-J+[specify match group]:group'
|
||||||
'!-V+:group' \
|
'!-V+:group'
|
||||||
'(-J -E)-1[remove only consecutive duplicates from group]' \
|
'(-J -E)-1[remove only consecutive duplicates from group]'
|
||||||
'-2[preserve all duplicates]' \
|
'-2[preserve all duplicates]'
|
||||||
'(-x)-X[specify explanation]:explanation' \
|
'(-x)-X[specify explanation]:explanation'
|
||||||
'(-X)-x[specify unconditional explanation]:explanation' \
|
'(-X)-x[specify unconditional explanation]:explanation'
|
||||||
'-q[make suffix autoremovable]' \
|
'-q[make suffix autoremovable]'
|
||||||
'-r+[specify character class for suffix autoremoval]:character class' \
|
'-r+[specify character class for suffix autoremoval]:character class'
|
||||||
'-R+[specify function for suffix autoremoval]:function:_functions' \
|
'-R+[specify function for suffix autoremoval]:function:_functions'
|
||||||
'-f[mark matches as being files]' \
|
'-F+[specify array of ignore patterns]:array:_parameters -g "*array*"'
|
||||||
'-e[mark matches as being parameters]' \
|
'-Q[disable quoting of possible completions]'
|
||||||
'-W[specify location for matches marked as files]' \
|
'*-M[specify matching specifications]'
|
||||||
'-F+[specify array of ignore patterns]:array:_parameters -g "*array*"' \
|
'-n[hide matches in completion listing]'
|
||||||
'-Q[disable quoting of possible completions]' \
|
'-O+[populate array with matches instead of adding them]:array:_parameters -g "*array*"'
|
||||||
'*-M[specify matching specifications]' \
|
'-A+[populate array with expanded matches instead of adding them]:array:_parameters -g "*array*"'
|
||||||
'-n[hide matches in completion listing]' \
|
'-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"'
|
||||||
'-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*"' \
|
case $service in
|
||||||
'-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"' \
|
compadd|_(path_|)files)
|
||||||
'-C[add special match that expands to all other matches]' \
|
args+=(
|
||||||
'(-1 -J)-E+[add specified number of display only matches]:number' \
|
'-W[specify location for matches marked as files]'
|
||||||
'*:candidate:->candidates' && ret=0
|
)
|
||||||
|
;|
|
||||||
|
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 [[ -n $state ]]; then
|
||||||
if (( $+opt_args[-a] )); then
|
if (( $+opt_args[-a] )); then
|
||||||
|
|
Loading…
Reference in a new issue