From 74ccd8d5a3d9e6f7e14d57f73d58d1319b99e9ca Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 9 Feb 2000 16:29:22 +0000 Subject: zsh-workers/9635 --- Completion/Core/_files | 67 ++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'Completion/Core/_files') diff --git a/Completion/Core/_files b/Completion/Core/_files index cd337713a..f02ac7c38 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -3,24 +3,21 @@ local opts opt type=file glob group gopts dopts aopts tmp _file_pat_checked=yes local hasign ign -opts=() -group=() -gopts=() -dopts=(-/) -aopts=(-f) -ign=() -while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do - case "$opt" in - /) type="${type}dir" ;; - g) type="${type}glob"; gopts=(-g "$OPTARG") ;; - [qn12]) opts=("$opts[@]" "-$opt" ) ;; - [JV]) group=( "-$opt" "$OPTARG") ;; - F) opts=("$opts[@]" "-$opt" "$OPTARG"); hasign=yes ;; - [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; - esac -done +zparseopts \ + /tmp ftmp g+tmp \ + qopts nopts 1opts 2opts P:opts S:opts r:opts R:opts W:opts X:opts M:opts \ + F:opts J:group V:group + +type="${(@j::M)${(@)tmp#-}#?}" +[[ -n "$type" ]] || type=f +if (( $tmp[(I)-g*] )); then + gopts=( -g ${(j: :)${(M)tmp:#-g*}#-g} ) +else + gopts=() +fi +(( $opts[(I)-F*] )) && hasign=yes -if [[ "$group[2]" = files ]]; then +if [[ "$group[1]" = -?files ]]; then opts=("$opts[@]" "$group[@]") group=() fi @@ -32,36 +29,36 @@ fi if zstyle -s ":completion:${curcontext}:directories" file-patterns tmp && [[ -n "$tmp" ]]; then dopts=(-g "$tmp") - if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then - type=glob - elif [[ "$type" != *(dir|glob)* ]]; then - type="${type}dir" + if [[ "$type" = (*/*g*|*g*/*) ]]; then + type=g + elif [[ "$type" != *[/g]* ]]; then + type="${type}/" fi fi if zstyle -s ":completion:${curcontext}:globbed-files" file-patterns tmp && [[ -n "$tmp" ]]; then gopts=(-g "$tmp") - if [[ "$type" != (*dir*glob*|*glob*dir*) ]]; then - if [[ "$type" = *(dir|glob)* ]]; then - type=glob + if [[ "$type" != (*/*g*|*g*/*) ]]; then + if [[ "$type" = *[g/]* ]]; then + type=g else - type=globall + type=ga fi fi fi case "$type" in -*dir*glob*|*glob*dir*) _tags globbed-files all-files ;; -*all*glob*|*glob*all*) _tags globbed-files all-files ;; -*glob*) _tags globbed-files directories all-files ;; -*dir*) _tags directories all-files ;; -*) _tags all-files ;; +*/*g*|*g*/*) _tags globbed-files all-files ;; +*a*g*|*g*a*) _tags globbed-files all-files ;; +*g*) _tags globbed-files directories all-files ;; +*/*) _tags directories all-files ;; +*) _tags all-files ;; esac while _tags; do if _requested all-files; then if (( $#group )); then - group[2]=all-files + group[1]="${group[1][1,2]}all-files" _setup all-files [[ -z "$hasign" ]] && zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore && @@ -72,7 +69,7 @@ while _tags; do elif _requested directories; then if _requested globbed-files; then if (( $#group )); then - group[2]=globbed-files + group[1]="${group[1][1,2]}globbed-files" _setup globbed-files [[ -z "$hasign" ]] && zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore && @@ -81,7 +78,7 @@ while _tags; do _path_files "$opts[@]" "$ign[@]" "$dopts[@]" "$gopts[@]" && return 0 else if (( $#group )); then - group[2]=directories + group[1]="${group[1][1,2]}directories" _setup directories [[ -z "$hasign" ]] && zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore && @@ -91,13 +88,13 @@ while _tags; do fi elif _requested globbed-files; then if (( $#group )); then - group[2]=globbed-files + group[1]="${group[1][1,2]}globbed-files" _setup globbed-files [[ -z "$hasign" ]] && zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore && ign=(-F _comp_ignore) fi - if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then + if [[ "$type" = (*/*g*|*g*/*) ]]; then _path_files "$opts[@]" "$ign[@]" "$dopts[@]" "$gopts[@]" && return 0 else _path_files "$opts[@]" "$ign[@]" "$gopts[@]" && return 0 -- cgit 1.4.1