diff options
author | Oliver Kiddle <okiddle@yahoo.co.uk> | 2019-05-07 23:24:49 +0200 |
---|---|---|
committer | Oliver Kiddle <okiddle@yahoo.co.uk> | 2019-05-07 23:24:49 +0200 |
commit | cd6fd2b0a3641774e7854ff8298d1d82643c4b4a (patch) | |
tree | 1b09fbc0dfed078e48c945352c6635a4a6bcbb04 /Completion/Base | |
parent | 5200637bda09e34da934e18f3c30f4b124d8d597 (diff) | |
download | zsh-cd6fd2b0a3641774e7854ff8298d1d82643c4b4a.tar.gz zsh-cd6fd2b0a3641774e7854ff8298d1d82643c4b4a.tar.xz zsh-cd6fd2b0a3641774e7854ff8298d1d82643c4b4a.zip |
44274: allow finer control of completion match soring with compadd's -o option
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/Core/_description | 32 | ||||
-rw-r--r-- | Completion/Base/Utility/_describe | 4 | ||||
-rw-r--r-- | Completion/Base/Utility/_guard | 2 | ||||
-rw-r--r-- | Completion/Base/Utility/_multi_parts | 4 | ||||
-rw-r--r-- | Completion/Base/Utility/_sep_parts | 4 | ||||
-rw-r--r-- | Completion/Base/Utility/_sequence | 3 |
6 files changed, 27 insertions, 22 deletions
diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description index 304c747a6..c2a0e080b 100644 --- a/Completion/Base/Core/_description +++ b/Completion/Base/Core/_description @@ -1,13 +1,13 @@ #autoload -local name gropt nopt xopt format gname hidden hide match opts tag sort +local name nopt xopt format gname hidden hide match opts tag +local -a gropt sort opts=() -gropt=(-J) xopt=(-X) nopt=() -zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt +zparseopts -K -D -a nopt 1 2 V=gropt J x=xopt 3="${${3##[[:blank:]]#}%%[[:blank:]]#}" [[ -n "$3" ]] && _lastdescr=( "$_lastdescr[@]" "$3" ) @@ -33,14 +33,18 @@ zstyle -s ":completion:${curcontext}:$1" matcher match && # Use sort style, but ignore `menu' value to help _expand. # Also don't override explicit use of -V. -if { zstyle -s ":completion:${curcontext}:$1" sort sort || - zstyle -s ":completion:${curcontext}:" sort sort; } && - [[ "$gropt" = -J && $sort != menu ]]; then - if [[ "$sort" = (yes|true|1|on) ]]; then - gropt=(-J) - else - gropt=(-V) +if [[ -z "$gropt" ]]; then + if zstyle -a ":completion:${curcontext}:$1" sort sort || + zstyle -a ":completion:${curcontext}:" sort sort + then + if [[ -z "${(@)sort:#(match|numeric|reverse)}" ]]; then + gropt=( -o ${(j.,.)sort} ) + elif [[ "$sort" != (yes|true|1|on|menu) ]]; then + gropt=( -o nosort ) fi + fi +else + gropt=( -o nosort ) fi if [[ -z "$_comp_no_ignore" ]]; then @@ -79,15 +83,15 @@ fi if [[ -n "$gname" ]]; then if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" fi else if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- fi fi diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe index 76ab1d995..c12eb0eab 100644 --- a/Completion/Base/Utility/_describe +++ b/Completion/Base/Utility/_describe @@ -108,10 +108,10 @@ while _tags; do fi if [[ -n $_mats ]]; then - compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs -O $_mats - \ + compadd "$_opts[@]" -2 -o nosort "${_expl[@]}" -D $_strs -O $_mats - \ "${(@)${(@M)${(@P)_mats}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}" else - compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \ + compadd "$_opts[@]" -2 -o nosort "${_expl[@]}" -D $_strs - \ "${(@)${(@M)${(@P)_strs}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}" fi done diff --git a/Completion/Base/Utility/_guard b/Completion/Base/Utility/_guard index ff62981ce..1cbd4f39b 100644 --- a/Completion/Base/Utility/_guard +++ b/Completion/Base/Utility/_guard @@ -2,7 +2,7 @@ local garbage -zparseopts -K -D -a garbage M: J: V: 1 2 n F: X: +zparseopts -K -D -a garbage M+: J+: V+: 1 2 o+: n F: X+: [[ "$PREFIX$SUFFIX" != $~1 ]] && return 1 diff --git a/Completion/Base/Utility/_multi_parts b/Completion/Base/Utility/_multi_parts index 12ff965ed..00e3e26cc 100644 --- a/Completion/Base/Utility/_multi_parts +++ b/Completion/Base/Utility/_multi_parts @@ -14,8 +14,8 @@ typeset -U tmp1 matches # Get the options. zparseopts -D -a sopts \ - 'J+:=group' 'V+:=group' 'X+:=expl' 'P:=opts' 'F:=opts' \ - S: r: R: q 1 2 n f 'M+:=matcher' 'i=imm' + 'J+:=group' 'V+:=group' 'x+:=expl' 'X+:=expl' 'P:=opts' 'F:=opts' \ + S: r: R: q 1 2 o+: n f 'M+:=matcher' 'i=imm' sopts=( "$sopts[@]" "$opts[@]" ) if (( $#matcher )); then diff --git a/Completion/Base/Utility/_sep_parts b/Completion/Base/Utility/_sep_parts index de836a696..6fcf54ec4 100644 --- a/Completion/Base/Utility/_sep_parts +++ b/Completion/Base/Utility/_sep_parts @@ -22,8 +22,8 @@ local matchflags opt group expl nm=$compstate[nmatches] opre osuf opts matcher # Get the options. -zparseopts -D -a opts \ - 'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 n 'X+:=expl' 'M+:=matcher' +zparseopts -D -a opts 'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 o+: n \ + 'x+:=expl' 'X+:=expl' 'M+:=matcher' # Get the string from the line. diff --git a/Completion/Base/Utility/_sequence b/Completion/Base/Utility/_sequence index f52955f46..101934490 100644 --- a/Completion/Base/Utility/_sequence +++ b/Completion/Base/Utility/_sequence @@ -10,7 +10,8 @@ local curcontext="$curcontext" nm="$compstate[nmatches]" pre qsep nosep minus local -a sep num pref suf end uniq dedup -zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf q=suf r:=suf R:=suf C:=cont d=uniq M: J: X: x: +zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf \ + q=suf r:=suf R:=suf C:=cont d=uniq M+: J+: V+: 1 2 o+: X+: x+: (( $#cont )) && curcontext="${curcontext%:*}:$cont[2]" (( $#sep )) || sep[2]=, |