From 5a774bf3cb4fa2d7a3eaa0df6013fc1150bdf944 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 7 Jan 2000 14:40:09 +0000 Subject: zsh-workers/9263 --- Completion/Builtins/_zmodload | 2 +- Completion/Core/_files | 27 ++++++++++++++++----------- Completion/Core/_path_files | 28 ++++++++++++++-------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload index bedc4b08f..c167df445 100644 --- a/Completion/Builtins/_zmodload +++ b/Completion/Builtins/_zmodload @@ -9,5 +9,5 @@ elif [[ "$fl" = -*u* ]]; then _wanted modules expl module && compadd "$expl[@]" - "${(@k)modules}" else _wanted files expl 'module file' && - compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r) + _files "$expl[@]" -W module_path -/g '*.s[ol](:r)' fi diff --git a/Completion/Core/_files b/Completion/Core/_files index a92771f80..f3eb0e5fc 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -1,16 +1,16 @@ #autoload -local opts opt type=file group +local opts opt type=file glob group opts=() group=() while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do case "$opt" in - /) [[ "$type" = file ]] && type=dir ;; - g) [[ "$type" = (file|dir) ]] && type="$OPTARG" ;; - [qn12]) opts=("$opts[@]" "-$opt" ) ;; - [JV]) group=( "-$opt" "$OPTARG") ;; - [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; + /) type="${type}dir" ;; + g) type="${type}glob"; glob="$OPTARG" ;; + [qn12]) opts=("$opts[@]" "-$opt" ) ;; + [JV]) group=( "-$opt" "$OPTARG") ;; + [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; esac done @@ -20,9 +20,10 @@ if [[ "$group[2]" = files ]]; then fi case "$type" in -file) _tags all-files ;; -dir) _tags directories all-files ;; -*) _tags globbed-files directories all-files ;; +*dir*glob*|*glob*dir) _tags globbed-files all-files ;; +*glob*) _tags globbed-files directories all-files ;; +*dir*) _tags directories all-files ;; +*) _tags all-files ;; esac while _tags; do @@ -39,7 +40,7 @@ while _tags; do group[2]=globbed-files _setup globbed-files fi - _path_files "$opts[@]" -/g "$type" && return 0 + _path_files "$opts[@]" -/g "$glob" && return 0 else if (( $#group )); then group[2]=directories @@ -52,7 +53,11 @@ while _tags; do group[2]=globbed-files _setup globbed-files fi - _path_files "$opts[@]" -g "$type" && return 0 + if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then + _path_files "$opts[@]" -/g "$glob" && return 0 + else + _path_files "$opts[@]" -g "$glob" && return 0 + fi fi done diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 4445ed3b4..51222bd9c 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -6,7 +6,7 @@ local linepath realpath donepath prepath testpath exppath local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre local pats haspats=no ignore group expl addpfx addsfx remsfx -local nm=$compstate[nmatches] menu match matcher mopts atmp sort +local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match typeset -U prepaths exppaths @@ -76,21 +76,21 @@ while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do pats=("$pats[@]" ${=OPTARG}) haspats=yes ;; - M) match="$OPTARG" + M) mspec="$OPTARG" matcher=(-M "$OPTARG") ;; esac done if (( ! ( $#group + $#expl ) )); then - if [[ "$sopt" = -/ ]]; then + if [[ -z "$gopt" && "$sopt" = -/ ]]; then _description directories expl directory else _description files expl file fi tmp1=$expl[(I)-M] if (( tmp1 )); then - match="$match $expl[1+tmp1]" + mspec="$mspec $expl[1+tmp1]" if (( $#matcher )); then matcher[2]="$matcher[2] $expl[1+tmp1]" else @@ -132,10 +132,10 @@ if zstyle -s ":completion${curcontext}:files" sort tmp1; then tmp2=() for tmp1 in "$pats[@]"; do - if [[ "$tmp1" = ?*\(\([^\|~]##\)\) ]]; then - tmp2=( "$tmp2[@]" "${tmp1[1,-3]}${sort}))" ) - elif [[ "$tmp1" = ?*\([^\|~]##\) ]]; then - tmp2=( "$tmp2[@]" "${tmp1[1,-2]}${sort})" ) + if [[ "$tmp1" = (#b)(?*)(\(\([^\|~]##\)\)) ]]; then + tmp2=( "$tmp2[@]" "${match[1]}((${sort}${match[2][3,-1]}" ) + elif [[ "$tmp1" = (#b)(?*)(\([^\|~]##\)) ]]; then + tmp2=( "$tmp2[@]" "${match[1]}(${sort}${match[2][2,-1]}" ) else tmp2=( "$tmp2[@]" "${tmp1}(${sort})" ) fi @@ -425,13 +425,13 @@ for prepath in "$prepaths[@]"; do compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \ + -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ - "${(@)tmp1%%/*}" else compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \ + -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ - "$tmp1[@]" fi else @@ -439,7 +439,7 @@ for prepath in "$prepaths[@]"; do atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" "$ignore[@]" "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" - -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" ) + -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" ) for i in "$tmp1[@]"; do compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}" done @@ -447,7 +447,7 @@ for prepath in "$prepaths[@]"; do compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \ + -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ - "$tmp1[@]" fi fi @@ -497,7 +497,7 @@ for prepath in "$prepaths[@]"; do compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \ + -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ - "$tmp1[@]" fi done @@ -513,7 +513,7 @@ if zstyle -t ":completion${curcontext}:paths" expand prefix && PREFIX="${opre}" SUFFIX="${osuf}" compadd -Q "$mopts[@]" -S '' "$group[@]" "$expl[@]" \ - -M "r:|/=* r:|=* $match" -p "$linepath" - "$exppaths[@]" + -M "r:|/=* r:|=* $mspec" -p "$linepath" - "$exppaths[@]" fi [[ nm -ne compstate[nmatches] ]] -- cgit 1.4.1