Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion of X colours
- X-seq: zsh-workers 46195
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: completion of X colours
- Date: Mon, 06 Jul 2020 17:49:19 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <8691-1594050559.938587.ref@nS9U.7ujg.aulP>
- Sender: zsh-workers@xxxxxxx
Completion of X colors seems to have stopped working at some point. This
makes it check if the showrgb command is installed and if so, uses it.
I've also taken the opportunity to rename the cache variable. Using
"cache" consistently as a prefix makes them easier to identify. And I
think we try to declare them explicitly with typeset -g now.
Oliver
diff --git a/Completion/X/Type/_x_color b/Completion/X/Type/_x_color
index 960eae6d3..845a35686 100644
--- a/Completion/X/Type/_x_color
+++ b/Completion/X/Type/_x_color
@@ -10,25 +10,28 @@
local expl
-if (( ! $+_color_cache )); then
+if (( ! $+_cache_x_colors )); then
+ typeset -ga _cache_x_colors
local file
# Cache of color names doesn't exist yet, create it.
zstyle -s ":completion:${curcontext}:colors" path file
if [[ -n "$file" ]]; then
- _color_cache=( "${(@)${(@f)$(< $file)}[2,-1]##* }" )
+ _cache_x_colors=( "${(@)${(@f)$(< $file)}[2,-1]##* }" )
+ elif (( $+commands[showrgb] )); then
+ _cache_x_colors=( "${(@)${(@)${(@f)$(_call_program colors showrgb)}[2,-1]##* }:#* *}" )
else
file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt(N) )
(( $#file )) &&
- _color_cache=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##* }:#* *}" )
+ _cache_x_colors=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##* }:#* *}" )
fi
# Stupid default value.
- (( $#_color_cache )) || _color_cache=(white black gray red blue green)
+ (( $#_cache_x_colors )) || _cache_x_colors=(white black gray red blue green)
fi
_wanted colors expl 'color specification' compadd "$@" -M \
- 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a - _color_cache
+ 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a - _cache_x_colors
Messages sorted by:
Reverse Date,
Date,
Thread,
Author