diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-03 13:47:39 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-03 13:47:39 +0000 |
commit | 97f02ffe63909c84cb9771d20a73ebec55f49589 (patch) | |
tree | 997db6027bc486992bdab800ed53404512446919 /Completion/Core/_files | |
parent | 3eeb83f1a0a01a16f137cef2dfc2c9d8c1626875 (diff) | |
download | zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.gz zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.xz zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.zip |
zsh-workers/8520
Diffstat (limited to 'Completion/Core/_files')
-rw-r--r-- | Completion/Core/_files | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/Completion/Core/_files b/Completion/Core/_files index 38eafd196..e667289c5 100644 --- a/Completion/Core/_files +++ b/Completion/Core/_files @@ -1,31 +1,27 @@ #autoload -# Utility function for completing files of a given type or any file. -# In many cases you will want to call this one instead of `_path_files'. - -local nm=$compstate[nmatches] ret=1 - -_path_files "$@" && ret=0 - -if [[ $# -ne 0 && compstate[nmatches] -eq nm ]]; then - local opt opts - - # We didn't get any matches for those types of files described by - # the `-g' or `-/' option. Now we try it again accepting all files. - # First we get those options that we have to use even then. If we - # find out that the `-f' option was given, we already accepted all - # files and give up immediatly. - - opts=() - while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:" opt; do - case "$opt" in - f) return;; - [PSrRWFJVXM]) opts=("$opts[@]" "-$opt" "$OPTARG");; - q) opts=("$opts[@]" -q);; - esac - done - - _path_files "$opts[@]" && ret=0 -fi - -return ret +local opts opt type=file prios tags + +opts=() +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 ) ;; + [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; + esac +done + +case "$type" in +file) _tags -f "$funcstack[2]" file ;; +dir) _tags -f "$funcstack[2]" path file ;; +*) _tags -f "$funcstack[2]" glob path file ;; +esac + +while _tags; do + [[ "$tags" = *:file:* ]] && { _path_files "$opts[@]" -f ; return } + [[ "$tags" = *:path:* ]] && _path_files "$opts[@]" -/ && return 0 + [[ "$tags" = *:glob:* ]] && _path_files "$opts[@]" -g "$type" && return 0 +done + +return 1 |