summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Core/_files25
-rw-r--r--Doc/Zsh/compsys.yo3
3 files changed, 21 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 439c889d0..9221cf24f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2000-04-06  Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
 
+	* Completion/Core/_files, Doc/Zsh/compsys.yo: tag in file-patterns
+ 	optional, use `files' as default (10542)
+
 	* 10531: Src/init.c: use `zsh' as command name in error messages
 	even with -c
 
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 0c0231cb4..7a4fdc3a0 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -1,6 +1,6 @@
 #autoload
 
-local opts tmp glob pats expl tag i pat descr end ign ret=1
+local opts tmp glob pat pats expl tag i def descr end ign ret=1
 
 zparseopts -a opts \
     '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
@@ -19,9 +19,16 @@ else
   ign=
 fi
 
-if zstyle -a ":completion:${curcontext}:" file-patterns pats; then
+if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
   [[ "$type" = */* ]] && glob="$glob *(-/)"
-  pats=( \ ${(M)^${pats//\\%p/ ${glob:-\*} }:#*[^\\]:*} )
+  pats=()
+  for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do
+    if [[ $i = *[^\\]:* ]]; then
+      pats=( "$pats[@]" " $i" )
+    else
+      pats=( "$pats[@]" " ${i}:files" )
+    fi
+  done
 else
   if [[ "$type" = *g* ]]; then
     if [[ "$type" = */* ]]; then
@@ -37,14 +44,14 @@ else
   fi
 fi
 
-for tag in "${(@)${(@)pats#*[^\\]:}%%:*}"; do
+for def in "$pats[@]"; do ###"${(@)${(@)pats#*[^\\]:}%%:*}"; do
 
-  i="$pats[(I)*[^\\\\]:${tag}(|:*)]"
-  pat="${${pats[i]%%:${tag}*}//\\\\:/:}"
+  tag="${${def#*[^\\]:}%%:*}"
+  pat="${${def%%:${tag}*}//\\\\:/:}"
 
-  if [[ i -gt 0 && "$pat" != \ # ]]; then
-    if [[ "$pats[i]" = *:${tag}:* ]]; then
-      descr="${pats[i]#*:${tag}:}"
+  if [[ "$pat" != \ # ]]; then
+    if [[ "$def" = *:${tag}:* ]]; then
+      descr="${def#*:${tag}:}"
     else
       descr=file
       end=yes
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index e8eada391..5ae068e4d 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -942,7 +942,8 @@ the pattern(s) given by the calling function.
 Colons in the pattern have to be preceded by a backslash to
 make them distinguishable from the colon before the var(tag). The
 var(tag)s of all strings in the value will be offered by tt(_files)
-(again, one after another) and used when looking up other styles. The
+(again, one after another) and used when looking up other styles. If
+no `tt(:)var(tag)' is given the tt(files) tag will be used. The
 var(tag) may also be
 followed by an optional second colon and a description. If that is
 given, this description will be used for the `tt(%d)' in the value of