about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-01-19 17:40:50 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-01-19 17:40:50 +0000
commitaf259b89dcf8d2ca74ebbb6cefb1db4de6336146 (patch)
tree81acc83d02c5925fecb4afc2cb8678bbde37700f /Completion
parent49ff05638b33ccf6a6531e141cbb55060caadbce (diff)
downloadzsh-af259b89dcf8d2ca74ebbb6cefb1db4de6336146.tar.gz
zsh-af259b89dcf8d2ca74ebbb6cefb1db4de6336146.tar.xz
zsh-af259b89dcf8d2ca74ebbb6cefb1db4de6336146.zip
zsh-workers/9371
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_files59
-rw-r--r--Completion/Core/_path_files14
2 files changed, 58 insertions, 15 deletions
diff --git a/Completion/Core/_files b/Completion/Core/_files
index f3eb0e5fc..1b16f4e67 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -1,16 +1,19 @@
 #autoload
 
-local opts opt type=file glob group
+local opts opt type=file glob group gopts dopts aopts tmp _file_pat_checked=yes
 
 opts=()
 group=()
+gopts=()
+dopts=(-/)
+aopts=(-f)
 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"; glob="$OPTARG"  ;;
-  [qn12]) opts=("$opts[@]" "-$opt"          ) ;;
-  [JV])   group=(          "-$opt" "$OPTARG") ;;
-  [^f])   opts=("$opts[@]" "-$opt" "$OPTARG") ;;
+  /)      type="${type}dir"                        ;;
+  g)      type="${type}glob"; gopts=(-g "$OPTARG") ;;
+  [qn12]) opts=("$opts[@]" "-$opt"          )      ;;
+  [JV])   group=(          "-$opt" "$OPTARG")      ;;
+  [^f])   opts=("$opts[@]" "-$opt" "$OPTARG")      ;;
   esac
 done
 
@@ -19,11 +22,37 @@ if [[ "$group[2]" = files ]]; then
   group=()
 fi
 
+if zstyle -s ":completion${curcontext}:all-files" file-patterns tmp &&
+   [[ -n "$tmp" ]]; then
+  aopts=(-g "$tmp")
+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"
+  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
+    else
+      type=globall
+    fi
+  fi
+fi
+
 case "$type" in
-*dir*glob*|*glob*dir) _tags globbed-files all-files             ;;
-*glob*)               _tags globbed-files directories all-files ;;
-*dir*)                _tags directories all-files               ;;
-*)                    _tags all-files                           ;;
+*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                           ;;
 esac
 
 while _tags; do
@@ -32,7 +61,7 @@ while _tags; do
       group[2]=all-files
       _setup all-files
     fi
-    _path_files "$opts[@]" -f
+    _path_files "$opts[@]" "$aopts[@]"
     return
   elif _requested directories; then
     if _requested globbed-files; then
@@ -40,13 +69,13 @@ while _tags; do
         group[2]=globbed-files
 	_setup globbed-files
       fi
-      _path_files "$opts[@]" -/g "$glob" && return 0
+      _path_files "$opts[@]" "$dopts[@]" "$gopts[@]" && return 0
     else
       if (( $#group )); then
         group[2]=directories
 	_setup directories
       fi
-      _path_files "$opts[@]" -/ && return 0
+      _path_files "$opts[@]" "$dopts[@]" && return 0
     fi
   elif _requested globbed-files; then
     if (( $#group )); then
@@ -54,9 +83,9 @@ while _tags; do
       _setup globbed-files
     fi
     if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
-      _path_files "$opts[@]" -/g "$glob" && return 0
+      _path_files "$opts[@]" "$dopts[@]" "$gopts[@]" && return 0
     else
-      _path_files "$opts[@]" -g "$glob" && return 0
+      _path_files "$opts[@]" "$gopts[@]" && return 0
     fi
   fi
 done
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index a53c5e10d..e76a54882 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -81,6 +81,20 @@ while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do
   esac
 done
 
+if [[ -z "$_file_pat_checked" ]] &&
+   zstyle -s ":completion${curcontext}:files" file-patterns tmp1 &&
+   [[ -n "$tmp1" ]]; then
+  if [[ "$tmp1" = '*(-/)' ]]; then
+    gopt=''
+    sopt=-/
+  else
+    gopt='-g'
+    sopt=-
+  fi
+  pats=( $=tmp1 )
+  haspats=yes
+fi
+
 if (( ! ( $#group + $#expl ) )); then
   if [[ -z "$gopt" && "$sopt" = -/ ]]; then
     _description directories expl directory