diff options
Diffstat (limited to 'Completion/Core')
-rw-r--r-- | Completion/Core/_alternative | 2 | ||||
-rw-r--r-- | Completion/Core/_description | 24 | ||||
-rw-r--r-- | Completion/Core/_files | 13 | ||||
-rw-r--r-- | Completion/Core/_parameters | 76 | ||||
-rw-r--r-- | Completion/Core/_path_files | 4 | ||||
-rw-r--r-- | Completion/Core/_requested | 12 | ||||
-rw-r--r-- | Completion/Core/_tags | 16 | ||||
-rw-r--r-- | Completion/Core/_wanted | 12 | ||||
-rw-r--r-- | Completion/Core/compinit | 3 |
9 files changed, 65 insertions, 97 deletions
diff --git a/Completion/Core/_alternative b/Completion/Core/_alternative index 76a8380bc..9d30884ae 100644 --- a/Completion/Core/_alternative +++ b/Completion/Core/_alternative @@ -25,7 +25,7 @@ while _tags; do descr="${${def#*:}%%:*}" action="${def#*:*:}" - _description expl "$descr" + _description "${def%%:*}" expl "$descr" if [[ "$action" = \ # ]]; then diff --git a/Completion/Core/_description b/Completion/Core/_description index 8cd9cc2fb..54518e49f 100644 --- a/Completion/Core/_description +++ b/Completion/Core/_description @@ -1,27 +1,33 @@ #autoload -local gropt=-J format +local gropt format gname -if [[ "$1" = -[VJ]* ]]; then - gropt="$1" +gropt=(-J) + +if [[ "$1" = -[VJ] ]]; then + gropt=("$1") + shift +elif [[ "$1" = -[VJ] ]]; then + gropt=("-${1[3,-1]}" "${1[1,2]}") shift fi -_lastdescr=( "$_lastdescr[@]" "$2" ) +_lastdescr=( "$_lastdescr[@]" "$3" ) _style -s descriptions format format +_style -s "$1" group-name gname && [[ -z "$gname" ]] && gname="$1" -if _style matches group; then +if [[ -n "$gname" ]]; then if [[ -n "$format" ]]; then - eval "$1=($gropt ${(q)2} -X ${(q)format//\\%d/$2})" + eval "$2=($gropt ${(q)gname} -X ${(q)format//\\%d/$3})" else - eval "$1=($gropt ${(q)2})" + eval "$2=($gropt ${(q)gname})" fi else if [[ -n "$format" ]]; then - eval "$1=(-X ${(q)format//\\%d/$2})" + eval "$2=(-J -default- -X ${(q)format//\\%d/$3})" else - eval "$1=()" + eval "$2=(-J -default-)" fi fi diff --git a/Completion/Core/_files b/Completion/Core/_files index ba5445797..9c5b45693 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -1,17 +1,24 @@ #autoload -local opts opt type=file +local opts opt type=file group opts=() +group=() while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:" opt; do case "$opt" in /) [[ "$type" = file ]] && type=dir ;; g) [[ "$type" = (file|dir) ]] && type="$OPTARG" ;; q) opts=("$opts[@]" -q ) ;; + [JV]) group=( "-$opt" "$OPTARG") ;; [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; esac done +if [[ "$group[2]" = files ]]; then + opts=("$opts[@]" "$group[@]") + group=() +fi + case "$type" in file) _tags all-files ;; dir) _tags directories all-files ;; @@ -20,15 +27,19 @@ esac while _tags; do if _requested all-files; then + (( $#group )) && group[2]=all-files _path_files "$opts[@]" -f return elif _requested directories; then if _requested globbed-files; then + (( $#group )) && group[2]=globbed-files _path_files "$opts[@]" -/g "$type" && return 0 else + (( $#group )) && group[2]=directories _path_files "$opts[@]" -/ && return 0 fi elif _requested globbed-files; then + (( $#group )) && group[2]=globbed-files _path_files "$opts[@]" -g "$type" && return 0 fi done diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters index 3735702df..c7875abcf 100644 --- a/Completion/Core/_parameters +++ b/Completion/Core/_parameters @@ -10,79 +10,3 @@ _wanted parameters expl parameter || return 1 pars=( ${(k)parameters[(R)^*local*]} ) compadd "$expl[@]" "$@" - $pars - - -# The `-e' option does everything for parameter expansions of us. If -# we wouldn't have it, we would use something like: - -# If the first argument is `-s' or `-b' auto_param_slash will be tested -# and slashes will be added to parameters containing a directory. `-s' is -# for parameter expansions without braces and `-b' is for expansions with -# braces. A `-' as the first argument is ignored and in all cases all -# other arguments will be given to `compadd'. - -# setopt localoptions extendedglob - -# local pars expl slash suf - -# if [[ "$1" = -s ]]; then -# slash=normal -# suf="$2" -# shift 2 -# elif [[ "$1" = -b ]]; then -# slash=brace -# suf="$2" -# shift 2 -# elif [[ "$1" = - ]]; then -# shift -# fi - -# _description expl parameter - -# if [[ -n "$slash" && -o autoparamslash ]]; then -# local i dirs nodirs ret=1 - -# dirs=() -# nodirs=() - -# if zmodload -e parameter; then -# setopt localoptions extendedglob -# nodirs=( ${(k)parameters[(R)undefined]} ) -# pars=( ${(k)parameters[(R)^*(local|undefined)*]} ) -# else -# nodirs=( ${${(M)${(f)"$(typeset +)"}:#undefined *}##* } ) -# pars=( ${${${(f)"$(typeset +)"}:#*(local|undefined) *}##* } ) -# fi - -# for i in $pars; do -# if [[ -d "${(P)i}" ]]; then -# dirs=( $dirs $i ) -# else -# nodirs=( $nodirs $i ) -# fi -# done - -# if [[ "$slash" = normal ]]; then -# compadd -S "/${suf%% #}" -r ' [/:' "$expl[@]" "$@" - $dirs && ret=0 -# compadd -S "$suf" -r ' [:' "$expl[@]" "$@" - $nodirs && ret=0 -# elif [[ "$slash" = brace ]]; then -# compadd -S "}/${suf%% #}" -r '-:?#%+=[/}' "$expl[@]" "$@" - $dirs && ret=0 -# compadd -S "}$suf" -r '-:?#%+=[/}' "$expl[@]" "$@" - $nodirs && ret=0 -# fi - -# return ret -# else -# if zmodload -e parameter; then -# pars=( ${(k)parameters[(R)^*local*]} ) -# else -# pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } ) -# fi - -# if [[ "$slash" = normal ]]; then -# compadd -S "$suf" -r ' [:' "$expl[@]" "$@" - $pars -# elif [[ "$slash" = brace ]]; then -# compadd -S "}$suf" -r '-:?#%+=[/}' "$expl[@]" "$@" - $pars -# else -# compadd "$expl[@]" "$@" - $pars -# fi -# fi diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 71ee3b218..2367def63 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -77,9 +77,9 @@ done if (( ! ( $#group + $#expl ) )); then if [[ "$sopt" = -/ ]]; then - _description expl directory + _description directories expl directory else - _description expl file + _description files expl file fi fi diff --git a/Completion/Core/_requested b/Completion/Core/_requested index 6641afdcf..3bc6f3b40 100644 --- a/Completion/Core/_requested +++ b/Completion/Core/_requested @@ -1,9 +1,17 @@ #autoload +local tag + +if [[ "$1" = -[VJ]* ]]; then + tag="$2" +else + tag="$1" +fi + comptags -C _cur_context -comptags -R "$1" && +comptags -R "$tag" && if [[ $# -gt 1 ]]; then - _description "${(@)argv[2,-1]}" + _description "$@" return 0 fi diff --git a/Completion/Core/_tags b/Completion/Core/_tags index 5294ab3c7..5519cc6cf 100644 --- a/Completion/Core/_tags +++ b/Completion/Core/_tags @@ -4,7 +4,7 @@ if (( $# )); then # We have arguments: the tags supported in this context. - local curcontext="$curcontext" + local curcontext="$curcontext" order if [[ "$1" = -C?* ]]; then curcontext="${curcontext}:${1[3,-1]}" @@ -18,6 +18,20 @@ if (( $# )); then [[ "$1" = -(|-) ]] && shift + + if _style -a '' group-order order; then + local name + + for name in "$order[@]"; do + compadd -J "$name" + compadd -V "$name" + compadd -J "$name" -1 + compadd -V "$name" -1 + compadd -J "$name" -2 + compadd -V "$name" -2 + done + fi + # Set and remember offered tags. comptags -i "$curcontext" "$@" diff --git a/Completion/Core/_wanted b/Completion/Core/_wanted index 7baa3e724..f95d74451 100644 --- a/Completion/Core/_wanted +++ b/Completion/Core/_wanted @@ -1,6 +1,6 @@ #autoload -local targs +local targs tag if [[ "$1" = -C?* ]]; then targs=( -C "${1[3,-1]}" ) @@ -12,10 +12,14 @@ else targs=() fi -[[ "$1" = -(|-) ]] && shift +if [[ "$1" = -[VJ]* ]]; then + tag="$2" +else + tag="$1" +fi if [[ $# -gt 1 ]]; then - _tags "$targs[@]" "$1" && _description "${(@)argv[2,-1]}" + _tags "$targs[@]" "$tag" && _description "$@" else - _tags "$targs[@]" "$1" + _tags "$targs[@]" "$tag" fi diff --git a/Completion/Core/compinit b/Completion/Core/compinit index 746b6c4d4..b313edede 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -326,6 +326,7 @@ your setup should be available in the file: \`${HOME}/.zsh-styles' +Note that the values for the style may not be fully correct. Have fun @@ -373,7 +374,7 @@ Have fun compstyle '*:options' prefix-hidden yes" ;; group_matches) - tmp="'*:matches' group 'yes'" + tmp="'*' group-name ''" ;; colors_path) tmp="'*:colors' path ${(qq)val}" |