* [PATCH] _files: "list-dirs-first" style.
@ 2008-08-16 7:06 Alexey I. Froloff
2008-08-18 9:57 ` Alexey I. Froloff
2008-08-21 15:54 ` Peter Stephenson
0 siblings, 2 replies; 4+ messages in thread
From: Alexey I. Froloff @ 2008-08-16 7:06 UTC (permalink / raw)
To: zsh workers; +Cc: Alexey I. Froloff
When this style set to "true", directories are shown before
files. Also instead of "all-files" tag it offers
"other-files" bceause directories are excluded from file
list. Screenshot:
user@host /usr/libexec $ ls <Tab>
---- directories ----
awk/ ConsoleKit/
dbus-1/ evolution-data-server/
gcc/ gnupg/
gvfs/ hal/
hasher-priv/ PolicyKit/
postfix/ sudo/
X11/ xscreensaver/
---- files ----
ck-collect-session-info*
This can also be done by setting "file-patterns" style to
'*(-/):directories:directories %p(^-/):other-files'
("directories" tag description is required to split groups),
but completion for "zmodload" command doesn't offer modules.
Another possible solution does not work either:
zstyle ':completion:*' file-patterns '*(-/):directories:directories %p:other-files'
zstyle ':completion:*:other-files' ignored-patterns '*(-/)'
"ignored-patterns" seems to be ignored by _path_files...
Signed-off-by: Alexey I. Froloff <raorn@altlinux.org>
---
Completion/Unix/Type/_files | 17 +++++++++++++++++
Completion/Zsh/Command/_zstyle | 1 +
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index a3545cb..4615a60 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 2bf2709..a181a7b 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -68,6 +68,7 @@ styles=(
last-prompt c:bool
list c:listwhen
list-colors c:
+ list-dirs-first c:bool
list-grouped c:bool
list-packed c:bool
list-prompt c:
--
1.5.6.5.GIT
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _files: "list-dirs-first" style.
2008-08-16 7:06 [PATCH] _files: "list-dirs-first" style Alexey I. Froloff
@ 2008-08-18 9:57 ` Alexey I. Froloff
2008-08-21 15:54 ` Peter Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: Alexey I. Froloff @ 2008-08-18 9:57 UTC (permalink / raw)
To: zsh workers
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
* Alexey I. Froloff <raorn@> [080816 11:19]:
> When this style set to "true", directories are shown before
> files. Also instead of "all-files" tag it offers
> "other-files" bceause directories are excluded from file
> list.
Tell me something about this patch, please? Is it good or bad?
--
Regards,
Sir Raorn.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _files: "list-dirs-first" style.
2008-08-16 7:06 [PATCH] _files: "list-dirs-first" style Alexey I. Froloff
2008-08-18 9:57 ` Alexey I. Froloff
@ 2008-08-21 15:54 ` Peter Stephenson
2008-08-22 20:04 ` Richard Hartmann
1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2008-08-21 15:54 UTC (permalink / raw)
To: zsh workers; +Cc: Alexey I. Froloff
On Sat, 16 Aug 2008 11:06:10 +0400
"Alexey I. Froloff" <raorn@altlinux.org> wrote:
> When this style set to "true", directories are shown before
> files. Also instead of "all-files" tag it offers
> "other-files" bceause directories are excluded from file
> list.
Thanks, this looks potentially useful and at worst harmless (haven't
quite worked out why you can't do it with tag ordering but they're
certainly fiddly and this is a common case). I've committed it with the
docs below.
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.213
diff -u -r1.213 compsys.yo
--- Doc/Zsh/compsys.yo 29 Jul 2008 08:39:41 -0000 1.213
+++ Doc/Zsh/compsys.yo 21 Aug 2008 15:50:11 -0000
@@ -928,6 +928,11 @@
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 @@
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
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _files: "list-dirs-first" style.
2008-08-21 15:54 ` Peter Stephenson
@ 2008-08-22 20:04 ` Richard Hartmann
0 siblings, 0 replies; 4+ messages in thread
From: Richard Hartmann @ 2008-08-22 20:04 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh workers, Alexey I. Froloff
On Thu, Aug 21, 2008 at 17:54, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> +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.
Wouldn't it make sense to change the name to something descriptive?
'other-files' is not something you can immediately associate anything with.
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-08-22 20:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-16 7:06 [PATCH] _files: "list-dirs-first" style Alexey I. Froloff
2008-08-18 9:57 ` Alexey I. Froloff
2008-08-21 15:54 ` Peter Stephenson
2008-08-22 20:04 ` Richard Hartmann
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).