about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-08-21 15:53:00 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-08-21 15:53:00 +0000
commitc0e501d8a53c1bc29f48c1e7cd94d6eb9601bb54 (patch)
tree2a2c0f4c60e62ba7f99508dd2a308a9bc13df7ac
parent46c4588a2b52262353a83d0284bcf7160f8cf5cd (diff)
downloadzsh-c0e501d8a53c1bc29f48c1e7cd94d6eb9601bb54.tar.gz
zsh-c0e501d8a53c1bc29f48c1e7cd94d6eb9601bb54.tar.xz
zsh-c0e501d8a53c1bc29f48c1e7cd94d6eb9601bb54.zip
Alexey I. Froloff: 25459: add list-dirs-first style.
Also doc.
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Unix/Type/_files17
-rw-r--r--Completion/Zsh/Command/_zstyle1
-rw-r--r--Doc/Zsh/compsys.yo13
4 files changed, 38 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ef943631..f56c99389 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-21  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* Doc/Zsh/compsys.yo: doc for foregoing.
+
+	* Alexey I. Froloff: 25459: Completion/Unix/Type/_files: add
+	list-dirs-first style.
+
 2008-08-21  Clint Adams  <clint@zsh.org>
 
 	* Mikael Magnusson: 25499: Completion/Unix/Command/_git: add
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index a3545cb54..4615a60e7 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -39,6 +39,23 @@ if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
       pats=( "$pats[@]" " ${i}:files " )
     fi
   done
+elif zstyle -t ":completion:${curcontext}:" list-dirs-first; then
+  if [[ "$type" = *g* ]]; then
+
+    # add `^-/' after `#q' glob qualifier if not there already
+    if [[ "$glob" = (#b)(*\(\#q)(*\)) ]]; then
+      [[ $match[2] != \^-/* ]] &&
+      glob="${match[1]}^-/,${match[2]}"
+    else
+      glob="$glob(#q^-/)"
+    fi
+
+    pats=( " *(-/):directories:directories ${glob//:/\\:}:globbed-files" )
+  elif [[ "$type" = */* ]] then
+    pats=( '*(-/):directories ' '*:all-files ' )
+  else
+    pats=( '*(-/):directories:directories *(^-/):other-files ' )
+  fi
 else
   if [[ "$type" = *g* ]]; then
 
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 04845fd5a..008061978 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -74,6 +74,7 @@ styles=(
   last-prompt		 c:bool
   list			 ce:listwhen
   list-colors		 c:
+  list-dirs-first	 c:bool
   list-grouped		 c:bool
   list-packed		 c:bool
   list-prompt            c:
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index b70b50297..498c8c0ce 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -928,6 +928,11 @@ kindex(other-accounts, completion tag)
 item(tt(other-accounts))(
 used to look up the tt(users-hosts) style
 )
+kindex(other-files, completion tag)
+item(tt(other-files))(
+for the names of any non-directory files.  This is used instead
+of tt(all-files) when the tt(list-dirs-first) style is in effect.
+)
 kindex(packages, completion tag)
 item(tt(packages))(
 for packages (e.g. tt(rpm) or installed tt(Debian) packages)
@@ -1854,6 +1859,14 @@ example(zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS})
 The default colors are the same as for the GNU tt(ls) command and can be
 obtained by setting the style to an empty string (i.e. tt('')).
 )
+kindex(list-dirs-first, completion style)
+item(tt(list-dirs-first))(
+This is used by file completion.  If set, directories to be completed
+are listed separately from and before completion for other files,
+regardless of tag ordering.  In addition, the tag tt(other-files)
+is used in place of tt(all-files) for the remaining files, to indicate
+that no directories are presented with that tag.
+)
 kindex(list-grouped, completion style)
 item(tt(list-grouped))(
 If this style is `true' (the default), the completion system will try to