Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: groups in ZLS_COLOURS (and questions)



I wrote:

> What this patch doesn't do is make this configurable with styles.
> That's because I'm not sure how to do that best. What I would like to
> achieve is that one could do, e.g.:
> 
>   compstyle '*:jobs' list-colors <specs...>
> 
> which would make the completion code use these patterns only for
> groups named `jobs'. Building appropriate specs for ZLS_* is
> simple. But there are three problems I see:

This patch does that (and the list-colors style for the default tag to 
get specs that are to be used everywhere).

NOTE: this means that the completion system has to change the
ZLS_COLORS parameter. So, if you have that set, it won't work for you
any more -- I couldn't think of a way to use the value stored in oe of 
the ZLS_* params as the defaults. Sorry. But you can easily convert
your definition to styles, just add:

  compstyle '*:default' list-colors ${(s.:.)ZLS_COLORS}

to your other compstyle stuff.


Or did anyone have a better idea?


Internals: this adds the function _setup to look up and styles and set 
ZLS_COLORS. This function will get somewhat bigger when we make more
things configurable with styles.

This also fixes a small typo/thinko in computil.c -- compstyles
couldn't be called without strings for the value.

Bye
 Sven

diff -u -r oldcompletion/Core/_description Completion/Core/_description
--- oldcompletion/Core/_description	Thu Dec  2 15:02:30 1999
+++ Completion/Core/_description	Fri Dec  3 09:23:29 1999
@@ -14,6 +14,8 @@
 
 _lastdescr=( "$_lastdescr[@]" "$3" )
 
+_setup "$1"
+
 _style -s descriptions format format
 _style -s "$1" group-name gname && [[ -z "$gname" ]] && gname="$1"
 
diff -u -r oldcompletion/Core/_files Completion/Core/_files
--- oldcompletion/Core/_files	Thu Dec  2 15:02:30 1999
+++ Completion/Core/_files	Fri Dec  3 09:23:29 1999
@@ -27,19 +27,31 @@
 
 while _tags; do
   if _requested all-files; then
-    (( $#group )) && group[2]=all-files
+    if (( $#group )); then
+      group[2]=all-files
+      _setup all-files
+    fi
     _path_files "$opts[@]" -f
     return
   elif _requested directories; then
     if _requested globbed-files; then
-      (( $#group )) && group[2]=globbed-files
+      if (( $#group )); then
+        group[2]=globbed-files
+	_setup globbed-files
+      fi
       _path_files "$opts[@]" -/g "$type" && return 0
     else
-      (( $#group )) && group[2]=directories
+      if (( $#group )); then
+        group[2]=directories
+	_setup directories
+      fi
       _path_files "$opts[@]" -/ && return 0
     fi
   elif _requested globbed-files; then
-    (( $#group )) && group[2]=globbed-files
+    if (( $#group )); then
+      group[2]=globbed-files
+      _setup globbed-files
+    fi
     _path_files "$opts[@]" -g "$type" && return 0
   fi
 done
diff -u -r oldcompletion/Core/_main_complete Completion/Core/_main_complete
--- oldcompletion/Core/_main_complete	Thu Dec  2 15:02:30 1999
+++ Completion/Core/_main_complete	Fri Dec  3 09:31:09 1999
@@ -39,6 +39,10 @@
   compstate[context]=tilde
 fi
 
+# Initial setup.
+
+_setup default
+
 # Get the names of the completers to use in the positional parameters.
 
 if (( ! $# )); then
diff -u -r oldcompletion/Core/compinit Completion/Core/compinit
--- oldcompletion/Core/compinit	Thu Dec  2 15:02:31 1999
+++ Completion/Core/compinit	Fri Dec  3 09:33:36 1999
@@ -487,12 +487,13 @@
 
 # Default styles. This should be executed conditionally somehow.
 
-compstyle '*'        verbose       'yes'
-compstyle '*'        prefix-needed 'yes'
-compstyle '*'        prefix-hidden 'no'
-compstyle ':correct' accept        '2n'
-compstyle ':correct' prompt        'correct to:'
-compstyle '*'        completer     '_complete'
+compstyle '*'         verbose       'yes'
+compstyle '*'         prefix-needed 'yes'
+compstyle '*'         prefix-hidden 'no'
+compstyle ':correct'  accept        '2n'
+compstyle ':correct'  prompt        'correct to:'
+compstyle '*'         completer     '_complete'
+compstyle '*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
 
 # Now we automatically make the definition files autoloaded.
 
diff -u olddoc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- olddoc/Zsh/compsys.yo	Thu Dec  2 15:02:09 1999
+++ Doc/Zsh/compsys.yo	Fri Dec  3 09:43:35 1999
@@ -964,6 +964,27 @@
 Like the tt(arguments) style, but used when calling the tt(ps) command 
 to generate the list to display.
 )
+item(tt(list-colors))(
+If the tt(complist) module is used, this style can be used to set
+color specifications as with the tt(ZLS_COLORS) and tt(ZLS_COLOURS)
+parameters (see
+ifzman(the section `The complist Module' in zmanref(zshmodules))\
+ifnzman(noderef(The complist Module))\
+).
+
+If this style is set for the tt(default) tag, the strings in the value 
+are taken as specifications that are to be used everywhere. If it is
+set for other tags, the specifications are used only for matches of
+the type described by the tag.
+
+To be able to share the same specifications one has set up for the GNU
+version of the tt(ls) command one can use:
+
+example(compstyle '*:default' list-colors ${(s.:.)LS_COLORS})
+
+And to get the default colors (which are the same as for the GNU
+tt(ls) command) one should set the style to an empty value.
+)
 item(tt(local))(
 This style is used by completion functions which generate URLs as
 possible matches to add suitable matches when a URL points to a
diff -u olddoc/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- olddoc/Zsh/compwid.yo	Thu Dec  2 15:02:09 1999
+++ Doc/Zsh/compwid.yo	Fri Dec  3 09:23:31 1999
@@ -372,7 +372,7 @@
 startitem()
 findex(compadd)
 cindex(completion widgets, adding specified matches)
-xitem(tt(compadd) [ tt(-qQfenUaml12) ] [ tt(-F) var(array) ])
+xitem(tt(compadd) [ tt(-qQfenUal12) ] [ tt(-F) var(array) ])
 xitem([ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ])
 xitem([ tt(-p) var(hidden-prefix) ] [ tt(-s) var(hidden-suffix) ])
 xitem([ tt(-i) var(ignored-prefix) ] [ tt(-I) var(ignored-suffix) ])
@@ -449,7 +449,7 @@
 )
 item(tt(-l))(
 This option only has an effect if used together with the tt(-d)
-options. If it is given, the display strings are listed one per line,
+option. If it is given, the display strings are listed one per line,
 not arrayed in columns.
 )
 item(tt(-J) var(name))(
diff -u olddoc/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
--- olddoc/Zsh/mod_complist.yo	Thu Dec  2 15:02:11 1999
+++ Doc/Zsh/mod_complist.yo	Fri Dec  3 09:23:31 1999
@@ -118,6 +118,13 @@
 vt100 compatible terminals such as tt(xterm)s. On monochrome terminals
 the default values will have no visual effect.
 
+If the shell function based completion system is used, these
+parameters should not be set directly because the system controls them 
+itself. Instead, the tt(list-colors) style should be used (see
+ifzman(the section `Completion System Configuration' in zmanref(zshcompsys))\
+ifnzman(noderef(Completion System Configuration))\
+).
+
 subsect(Menu selection)
 cindex(completion, selecting by cursor)
 vindex(SELECTMIN)
diff -u oldsrc/Zle/computil.c Src/Zle/computil.c
--- oldsrc/Zle/computil.c	Thu Dec  2 15:02:05 1999
+++ Src/Zle/computil.c	Fri Dec  3 09:43:21 1999
@@ -2436,7 +2436,7 @@
 	return 1;
     }
     switch (args[0][1]) {
-    case 'a': min = 3; max = -1; break;
+    case 'a': min = 2; max = -1; break;
     case 'd': min = 0; max =  2; break;
     case 'S': min = 3; max =  3; break;
     case 'A': min = 3; max =  3; break;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author