about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-10-09 12:56:02 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-10-09 12:56:02 +0000
commit933813e971a4a9d9fd5911226935c9be55a87f13 (patch)
tree9e3fd443c83d35939b3fab0df4f762c4a8c16049 /Completion
parent2a2de0abeac1ce7295be907bdb13e795d94a67f0 (diff)
downloadzsh-933813e971a4a9d9fd5911226935c9be55a87f13.tar.gz
zsh-933813e971a4a9d9fd5911226935c9be55a87f13.tar.xz
zsh-933813e971a4a9d9fd5911226935c9be55a87f13.zip
change file completion default to offer globbed files and directories on first try (15995)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Type/_files40
1 files changed, 30 insertions, 10 deletions
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index 87234eb2d..fa98ce574 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -37,12 +37,25 @@ if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
   done
 else
   if [[ "$type" = *g* ]]; then
-    if [[ "$type" = */* ]]; then
-      pats=( " ${glob//:/\\:}:globbed-files *(-/):directories" '*:all-files ' )
-    else
-      pats=( " ${glob//:/\\:}:globbed-files "
-             '*(-/):directories ' '*:all-files ' )
-    fi
+
+  # People prefer to have directories shown on first try as default.
+  # Even if the calling function didn't use -/.
+  #
+  # if [[ "$type" = */* ]]; then
+
+    pats=( " ${glob//:/\\:}:globbed-files *(-/):directories" '*:all-files '
+
+    ### We could allow _next_tags to offer only globbed-files or directories
+    ### by adding:
+    ###   " ${glob//:/\\:}:only-globbed-files " ' *(-/):only-directories '
+
+      )
+
+  # else
+  #   pats=( " ${glob//:/\\:}:globbed-files "
+  #          '*(-/):directories ' '*:all-files ' )
+  # fi
+
   elif [[ "$type" = */* ]]; then
     pats=( '*(-/):directories ' '*:all-files ' )
   else
@@ -53,15 +66,16 @@ fi
 tried=()
 for def in "$pats[@]"; do
   eval "def=( ${${def:gs/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
+
+  tmp="${(@M)def#*[^\\]:}"
+  (( $tried[(I)${(q)tmp}] )) && continue
+  tried=( "$tried[@]" "$tmp" )
+
   for sdef in "$def[@]"; do
 
     tag="${${sdef#*[^\\]:}%%:*}"
     pat="${${sdef%%:${tag}*}//\\:/:}"
 
-    (( $tried[(I)${(q)pat}] )) && continue
-
-    tried=( "$tried[@]" "$pat" )
-
     if [[ "$sdef" = *:${tag}:* ]]; then
       descr="${(Q)sdef#*:${tag}:}"
     else
@@ -86,7 +100,13 @@ for def in "$pats[@]"; do
       done
       (( ret )) || break
     done
+
+    ### For that _next_tags change mentioned above we would have to
+    ### comment out the following line. (Or not, depending on the order
+    ### of the patterns.)
+
     [[ "$pat" = '*' ]] && return ret
+
   done
   (( ret )) || return 0
 done