about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:54:26 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:54:26 +0000
commitddb16a1b2b2426f14daa54e6ee759bea64f3cb55 (patch)
tree9565d21ca50cbe033a3400774d0e9a5903820ebc /Completion
parent9ecbacab6b041c12f2dd3eb1f78ba69ccbff100d (diff)
downloadzsh-ddb16a1b2b2426f14daa54e6ee759bea64f3cb55.tar.gz
zsh-ddb16a1b2b2426f14daa54e6ee759bea64f3cb55.tar.xz
zsh-ddb16a1b2b2426f14daa54e6ee759bea64f3cb55.zip
allow to anchor on gaps between strings in matching control specs (10926)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/X/_x_color31
1 files changed, 21 insertions, 10 deletions
diff --git a/Completion/X/_x_color b/Completion/X/_x_color
index 346142eea..8df656fe1 100644
--- a/Completion/X/_x_color
+++ b/Completion/X/_x_color
@@ -1,5 +1,13 @@
 #autoload
 
+# This tries to automatically find the rgb.txt color database. If this
+# in an unusual place on your system or you want a personal database,
+# you can use the configuration key:
+#
+#  colors_path
+#    Path to a file containing the names of colors you want to
+#    complete. In the form of a X11 rgb.txt file.
+
 local expl
 
 if (( ! $+_color_cache )); then
@@ -7,18 +15,21 @@ if (( ! $+_color_cache )); then
 
   # Cache of color names doesn't exist yet, create it.
 
-  file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt(N) )
-
-  if (( $#file )); then
-    _color_cache=( "${(@)${(@f)$(< $file[1])}[2,-1]##*		}" )
+  zstyle -s ":completion:${curcontext}:colors" path file
+  if [[ -n "$file" ]]; then
+    _color_cache=( "${(@)${(@f)$(< $file)}[2,-1]##*		}" )
   else
+    file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt(N) )
 
-    # Stupid default value.
-
-    _color_cache=(white black gray red blue green)
+    (( $#file )) &&
+        _color_cache=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##*		}:#* *}" )
   fi
+
+  # Stupid default value.
+
+  (( $#_color_cache )) || _color_cache=(white black gray red blue green)
 fi
 
-_description expl 'color specification'
-compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} m:-=\  r:|[ A-Z0-9]=* r:|=*' - \
-        "$_color_cache[@]"
+_wanted colors expl 'color specification' \
+    compadd "$@" -M 'm:{a-z}={A-Z} m:-=\  r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' - \
+            "$_color_cache[@]"