unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6332: Colors lost from list-colors-display
@ 2010-06-02 19:38 Juri Linkov
  2010-06-03 19:31 ` Juri Linkov
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Juri Linkov @ 2010-06-02 19:38 UTC (permalink / raw)
  To: 6332

A few years ago I customized the color of `font-lock-string-face' to
"dark green".  Now I wanted to customize `font-lock-doc-face', but alas
it's not possible anymore to select this color from the list of colors.
I can find "dark green" and "DarkGreen" in etc/rgb.txt, but not in x-colors.

What was the reason of removing colors?  etc/rgb.txt contains 752 colors,
but x-colors now contains only 546.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-02 19:38 bug#6332: Colors lost from list-colors-display Juri Linkov
@ 2010-06-03 19:31 ` Juri Linkov
  2010-06-04  8:42   ` Eli Zaretskii
  2010-06-04 16:07   ` Chong Yidong
  2010-06-04 10:48 ` Juanma Barranquero
  2010-06-12 17:13 ` Chong Yidong
  2 siblings, 2 replies; 21+ messages in thread
From: Juri Linkov @ 2010-06-03 19:31 UTC (permalink / raw)
  To: 6332

> What was the reason of removing colors?  etc/rgb.txt contains 752 colors,
> but x-colors now contains only 546.

The comment added 2008-05-10 (revno#87519) says that the ordering of the
colors is chosen for the user's convenience in `list-colors-display'.

But later at 2009-08-05 I provided a patch that adds a new option
`list-colors-sort' that defines the sorting order for `list-colors-display':
http://thread.gmane.org/gmane.emacs.devel/113422/focus=113687

I propose to revert 2008-05-10 change, so `x-colors' will be again the
complete copy of etc/rgb.txt.  And to install my patch that implements the
current sorting order in `x-colors' as the default value of the new option
`list-colors-sort'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-03 19:31 ` Juri Linkov
@ 2010-06-04  8:42   ` Eli Zaretskii
  2010-06-04 16:33     ` Juri Linkov
  2010-06-04 16:07   ` Chong Yidong
  1 sibling, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2010-06-04  8:42 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

> From: Juri Linkov <juri@jurta.org>
> Date: Thu, 03 Jun 2010 22:31:55 +0300
> Cc: 
> 
> > What was the reason of removing colors?  etc/rgb.txt contains 752 colors,
> > but x-colors now contains only 546.
> 
> The comment added 2008-05-10 (revno#87519) says that the ordering of the
> colors is chosen for the user's convenience in `list-colors-display'.
> 
> But later at 2009-08-05 I provided a patch that adds a new option
> `list-colors-sort' that defines the sorting order for `list-colors-display':
> http://thread.gmane.org/gmane.emacs.devel/113422/focus=113687
> 
> I propose to revert 2008-05-10 change, so `x-colors' will be again the
> complete copy of etc/rgb.txt.  And to install my patch that implements the
> current sorting order in `x-colors' as the default value of the new option
> `list-colors-sort'.

Can you show the differences between the list before and after the
change you suggest?  Can someone else please do that on MS-Windows?

I don't think we can decide on this without seeing the results first.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-02 19:38 bug#6332: Colors lost from list-colors-display Juri Linkov
  2010-06-03 19:31 ` Juri Linkov
@ 2010-06-04 10:48 ` Juanma Barranquero
  2010-06-04 16:19   ` Juri Linkov
  2010-06-12 17:13 ` Chong Yidong
  2 siblings, 1 reply; 21+ messages in thread
From: Juanma Barranquero @ 2010-06-04 10:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

On Wed, Jun 2, 2010 at 21:38, Juri Linkov <juri@jurta.org> wrote:

> What was the reason of removing colors?  etc/rgb.txt contains 752 colors,

etc/rgb.txt contains 752 names of colors, but just 502 different RGB triplets.

C:> perl -ne "/^ *[0-9]+/ and do {@t=split; print join(',', @t[0..2]),
$/}" < rgb.txt | sort | uniq | wc -l
502

    Juanma





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-03 19:31 ` Juri Linkov
  2010-06-04  8:42   ` Eli Zaretskii
@ 2010-06-04 16:07   ` Chong Yidong
  2010-06-04 16:20     ` Juri Linkov
  1 sibling, 1 reply; 21+ messages in thread
From: Chong Yidong @ 2010-06-04 16:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

Juri Linkov <juri@jurta.org> writes:

> The comment added 2008-05-10 (revno#87519) says that the ordering of the
> colors is chosen for the user's convenience in `list-colors-display'.
>
> But later at 2009-08-05 I provided a patch that adds a new option
> `list-colors-sort' that defines the sorting order for `list-colors-display':
> http://thread.gmane.org/gmane.emacs.devel/113422/focus=113687
>
> I propose to revert 2008-05-10 change, so `x-colors' will be again the
> complete copy of etc/rgb.txt.  And to install my patch that implements the
> current sorting order in `x-colors' as the default value of the new option
> `list-colors-sort'.

Please don't revert the 2008-05-10 change.  The current order is quite
deliberate, as the comment in common-win.el makes clear:

  ;; The ordering of the colors is chosen for the user's convenience in
  ;; `list-colors-display', which displays the reverse of this list.
  ;; Roughly speaking, `list-colors-display' orders by (i) named shades
  ;; of grey with hue 0.0, sorted by value (ii) named colors with
  ;; saturation 1.0, sorted by hue, (iii) named non-white colors with
  ;; saturation less than 1.0, sorted by hue, (iv) other named shades of
  ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
  ;; of grey.

I have experimented with pure HSV ordering, and the results were
unsatisfactory, as it breaks apart groups of clearly-related color names
(e.g. purple[1-4]).  I don't object to adding an option that controls
how the colors are sorted.  However, the default must be a
human-specified ordering, since there is never any satisfactory way to
map a multi-dimensional space into one dimension.

It should be noted that while only the colors listed in `x-colors' are
displayed by list-colors-display, Emacs recognizes any color in rgb.txt.
So even if "dark green" is not in x-colors, setting a face color to
"dark green" still works.  Some of the colors in rgb.txt have duplicate
names, and I think are rightly omitted from x-colors.  For instance,
there is no need for us to list "grey99" and "gray99" separately.

Dark green itself, however, was inadvertently omitted.  I will add it
back (along with some other ommitted colors).





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 10:48 ` Juanma Barranquero
@ 2010-06-04 16:19   ` Juri Linkov
  2010-06-04 17:26     ` Juanma Barranquero
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 16:19 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 6332

> On Wed, Jun 2, 2010 at 21:38, Juri Linkov <juri@jurta.org> wrote:
>
>> What was the reason of removing colors?  etc/rgb.txt contains 752 colors,
>
> etc/rgb.txt contains 752 names of colors, but just 502 different RGB triplets.
>
> C:> perl -ne "/^ *[0-9]+/ and do {@t=split; print join(',', @t[0..2]),
> $/}" < rgb.txt | sort | uniq | wc -l
> 502

This is ok, `list-colors-display' already removes duplicated color names
with the help of `list-colors-duplicates'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 16:07   ` Chong Yidong
@ 2010-06-04 16:20     ` Juri Linkov
  0 siblings, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 16:20 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 6332

> The current order is quite deliberate, as the comment in common-win.el
> makes clear:
>
>   ;; The ordering of the colors is chosen for the user's convenience in
>   ;; `list-colors-display', which displays the reverse of this list.
>   ;; Roughly speaking, `list-colors-display' orders by (i) named shades
>   ;; of grey with hue 0.0, sorted by value (ii) named colors with
>   ;; saturation 1.0, sorted by hue, (iii) named non-white colors with
>   ;; saturation less than 1.0, sorted by hue, (iv) other named shades of
>   ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
>   ;; of grey.
>
> I have experimented with pure HSV ordering, and the results were
> unsatisfactory, as it breaks apart groups of clearly-related color names
> (e.g. purple[1-4]).  I don't object to adding an option that controls
> how the colors are sorted.  However, the default must be a
> human-specified ordering, since there is never any satisfactory way to
> map a multi-dimensional space into one dimension.

Actually, I don't care about the default because there is no good
default scheme.  That's why leaving the human-specified ordering
of rgb.txt would be a good idea.  Or at least, allow an sorting option
that will sort colors by their order in rgb.txt.

> It should be noted that while only the colors listed in `x-colors' are
> displayed by list-colors-display, Emacs recognizes any color in rgb.txt.
> So even if "dark green" is not in x-colors, setting a face color to
> "dark green" still works.  Some of the colors in rgb.txt have duplicate
> names, and I think are rightly omitted from x-colors.  For instance,
> there is no need for us to list "grey99" and "gray99" separately.

With a full list of colors, `list-colors-display' already takes care of
duplicated color names, and displays different names on the same line, e.g.

dim gray               dim grey, DimGray, DimGrey

Please keep this because it is much easier to find the necessary color
using Isearch with one of the variant, i.e. if the user doesn't remember
which variant of gray/grey is preferred, the user can search for either
"gray" or "grey", and still find the color.

Please leave all colors from rgb.txt in x-colors because they help
to find the color by the color name in the *Colors* buffer.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04  8:42   ` Eli Zaretskii
@ 2010-06-04 16:33     ` Juri Linkov
  2010-06-04 17:01       ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 16:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 6332

> Can you show the differences between the list before and after the
> change you suggest?  Can someone else please do that on MS-Windows?

=== modified file 'lisp/term/common-win.el'
--- lisp/term/common-win.el	2010-01-13 08:35:10 +0000
+++ lisp/term/common-win.el	2010-06-04 16:23:12 +0000
@@ -194,100 +194,761 @@ (defun x-handle-args (args)
 
 (defvar x-colors
-  (purecopy 
-   '("gray100" "gray99" "gray98" "gray97" "gray96" "gray95" "gray94" "gray93" "gray92"
-    "gray91" "gray90" "gray89" "gray88" "gray87" "gray86" "gray85" "gray84" "gray83"
-    "gray82" "gray81" "gray80" "gray79" "gray78" "gray77" "gray76" "gray75" "gray74"
-    "gray73" "gray72" "gray71" "gray70" "gray69" "gray68" "gray67" "gray66" "gray65"
-    "gray64" "gray63" "gray62" "gray61" "gray60" "gray59" "gray58" "gray57" "gray56"
-    "gray55" "gray54" "gray53" "gray52" "gray51" "gray50" "gray49" "gray48" "gray47"
-    "gray46" "gray45" "gray44" "gray43" "gray42" "gray41" "gray40" "gray39" "gray38"
-    "gray37" "gray36" "gray35" "gray34" "gray33" "gray32" "gray31" "gray30" "gray29"
-    "gray28" "gray27" "gray26" "gray25" "gray24" "gray23" "gray22" "gray21" "gray20"
-    "gray19" "gray18" "gray17" "gray16" "gray15" "gray14" "gray13" "gray12" "gray11"
-    "gray10" "gray9" "gray8" "gray7" "gray6" "gray5" "gray4" "gray3" "gray2" "gray1"
-    "gray0" "LightPink1" "LightPink2" "LightPink3" "LightPink4" "pink1" "pink2" "pink3"
-    "pink4" "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
-    "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4" "VioletRed1"
-    "VioletRed2" "VioletRed3" "VioletRed4" "HotPink1" "HotPink2" "HotPink3" "HotPink4"
-    "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4" "maroon1" "maroon2" "maroon3"
-    "maroon4" "orchid1" "orchid2" "orchid3" "orchid4" "plum1" "plum2" "plum3" "plum4"
-    "thistle1" "thistle2" "thistle3" "thistle4" "MediumOrchid1" "MediumOrchid2"
-    "MediumOrchid3" "MediumOrchid4" "DarkOrchid1" "DarkOrchid2" "DarkOrchid3"
-    "DarkOrchid4" "purple1" "purple2" "purple3" "purple4" "MediumPurple1"
-    "MediumPurple2" "MediumPurple3" "MediumPurple4" "SlateBlue1" "SlateBlue2"
-    "SlateBlue3" "SlateBlue4" "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
-    "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4" "SlateGray1"
-    "SlateGray2" "SlateGray3" "SlateGray4" "DodgerBlue1" "DodgerBlue2" "DodgerBlue3"
-    "DodgerBlue4" "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4" "SkyBlue1"
-    "SkyBlue2" "SkyBlue3" "SkyBlue4" "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3"
-    "LightSkyBlue4" "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4" "CadetBlue1"
-    "CadetBlue2" "CadetBlue3" "CadetBlue4" "azure1" "azure2" "azure3" "azure4"
-    "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4" "PaleTurquoise1"
-    "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4" "DarkSlateGray1" "DarkSlateGray2"
-    "DarkSlateGray3" "DarkSlateGray4" "aquamarine1" "aquamarine2" "aquamarine3"
-    "aquamarine4" "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4" "honeydew1"
-    "honeydew2" "honeydew3" "honeydew4" "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3"
-    "DarkSeaGreen4" "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
-    "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4" "OliveDrab1"
-    "OliveDrab2" "OliveDrab3" "OliveDrab4" "ivory1" "ivory2" "ivory3" "ivory4"
-    "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4" "khaki1" "khaki2"
-    "khaki3" "khaki4" "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
-    "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4" "cornsilk1"
-    "cornsilk2" "cornsilk3" "cornsilk4" "goldenrod1" "goldenrod2" "goldenrod3"
-    "goldenrod4" "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
-    "wheat1" "wheat2" "wheat3" "wheat4" "NavajoWhite1" "NavajoWhite2" "NavajoWhite3"
-    "NavajoWhite4" "burlywood1" "burlywood2" "burlywood3" "burlywood4" "AntiqueWhite1"
-    "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4" "bisque1" "bisque2" "bisque3"
-    "bisque4" "tan1" "tan2" "tan3" "tan4" "PeachPuff1" "PeachPuff2" "PeachPuff3"
-    "PeachPuff4" "seashell1" "seashell2" "seashell3" "seashell4" "chocolate1"
-    "chocolate2" "chocolate3" "chocolate4" "sienna1" "sienna2" "sienna3" "sienna4"
-    "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4" "salmon1" "salmon2"
-    "salmon3" "salmon4" "coral1" "coral2" "coral3" "coral4" "tomato1" "tomato2"
-    "tomato3" "tomato4" "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4" "snow1"
-    "snow2" "snow3" "snow4" "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
-    "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4" "firebrick1" "firebrick2"
-    "firebrick3" "firebrick4" "brown1" "brown2" "brown3" "brown4" "magenta1" "magenta2"
-    "magenta3" "magenta4" "blue1" "blue2" "blue3" "blue4" "DeepSkyBlue1" "DeepSkyBlue2"
-    "DeepSkyBlue3" "DeepSkyBlue4" "turquoise1" "turquoise2" "turquoise3" "turquoise4"
-    "cyan1" "cyan2" "cyan3" "cyan4" "SpringGreen1" "SpringGreen2" "SpringGreen3"
-    "SpringGreen4" "green1" "green2" "green3" "green4" "chartreuse1" "chartreuse2"
-    "chartreuse3" "chartreuse4" "yellow1" "yellow2" "yellow3" "yellow4" "gold1" "gold2"
-    "gold3" "gold4" "orange1" "orange2" "orange3" "orange4" "DarkOrange1" "DarkOrange2"
-    "DarkOrange3" "DarkOrange4" "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
-    "red1" "red2" "red3" "red4" "lavender blush" "ghost white" "lavender" "alice blue"
-    "azure" "light cyan" "mint cream" "honeydew" "ivory" "light goldenrod yellow"
-    "light yellow" "beige" "floral white" "old lace" "blanched almond" "moccasin"
-    "papaya whip" "bisque" "antique white" "linen" "peach puff" "seashell" "misty rose"
-    "snow" "light pink" "pink" "hot pink" "deep pink" "maroon" "pale violet red"
-    "violet red" "medium violet red" "violet" "plum" "thistle" "orchid" "medium orchid"
-    "dark orchid" "purple" "blue violet" "medium purple" "light slate blue"
-    "medium slate blue" "slate blue" "dark slate blue" "midnight blue" "navy"
-    "dark blue" "light steel blue" "cornflower blue" "dodger blue" "royal blue"
-    "light slate gray" "slate gray" "dark slate gray" "steel blue" "cadet blue"
-    "light sky blue" "sky blue" "light blue" "powder blue" "pale turquoise" "turquoise"
-    "medium turquoise" "dark cyan" "aquamarine" "medium aquamarine" "light sea green"
-    "medium sea green" "sea green" "dark sea green" "pale green" "lime green"
-    "forest green" "light green" "green yellow" "yellow green" "olive drab"
-    "dark olive green" "lemon chiffon" "khaki" "dark khaki" "cornsilk"
-    "pale goldenrod" "light goldenrod" "goldenrod" "dark goldenrod" "wheat"
-    "navajo white" "tan" "burlywood" "sandy brown" "peru" "chocolate" "saddle brown"
-    "sienna" "rosy brown" "dark salmon" "coral" "tomato" "light salmon" "salmon"
-    "light coral" "indian red" "firebrick" "brown" "dark red" "magenta"
-    "dark magenta" "dark violet" "medium blue" "blue" "deep sky blue"
-    "cyan" "medium spring green" "spring green" "green" "lawn green" "chartreuse"
-    "yellow" "gold" "orange" "dark orange" "orange red" "red" "white" "white smoke"
-    "gainsboro" "light grey" "gray" "dark grey" "dim gray" "black" ))
+  (purecopy
+   '("LightGreen"
+     "light green"
+     "DarkRed"
+     "dark red"
+     "DarkMagenta"
+     "dark magenta"
+     "DarkCyan"
+     "dark cyan"
+     "DarkBlue"
+     "dark blue"
+     "DarkGray"
+     "dark gray"
+     "DarkGrey"
+     "dark grey"
+     "grey100"
+     "gray100"
+     "grey99"
+     "gray99"
+     "grey98"
+     "gray98"
+     "grey97"
+     "gray97"
+     "grey96"
+     "gray96"
+     "grey95"
+     "gray95"
+     "grey94"
+     "gray94"
+     "grey93"
+     "gray93"
+     "grey92"
+     "gray92"
+     "grey91"
+     "gray91"
+     "grey90"
+     "gray90"
+     "grey89"
+     "gray89"
+     "grey88"
+     "gray88"
+     "grey87"
+     "gray87"
+     "grey86"
+     "gray86"
+     "grey85"
+     "gray85"
+     "grey84"
+     "gray84"
+     "grey83"
+     "gray83"
+     "grey82"
+     "gray82"
+     "grey81"
+     "gray81"
+     "grey80"
+     "gray80"
+     "grey79"
+     "gray79"
+     "grey78"
+     "gray78"
+     "grey77"
+     "gray77"
+     "grey76"
+     "gray76"
+     "grey75"
+     "gray75"
+     "grey74"
+     "gray74"
+     "grey73"
+     "gray73"
+     "grey72"
+     "gray72"
+     "grey71"
+     "gray71"
+     "grey70"
+     "gray70"
+     "grey69"
+     "gray69"
+     "grey68"
+     "gray68"
+     "grey67"
+     "gray67"
+     "grey66"
+     "gray66"
+     "grey65"
+     "gray65"
+     "grey64"
+     "gray64"
+     "grey63"
+     "gray63"
+     "grey62"
+     "gray62"
+     "grey61"
+     "gray61"
+     "grey60"
+     "gray60"
+     "grey59"
+     "gray59"
+     "grey58"
+     "gray58"
+     "grey57"
+     "gray57"
+     "grey56"
+     "gray56"
+     "grey55"
+     "gray55"
+     "grey54"
+     "gray54"
+     "grey53"
+     "gray53"
+     "grey52"
+     "gray52"
+     "grey51"
+     "gray51"
+     "grey50"
+     "gray50"
+     "grey49"
+     "gray49"
+     "grey48"
+     "gray48"
+     "grey47"
+     "gray47"
+     "grey46"
+     "gray46"
+     "grey45"
+     "gray45"
+     "grey44"
+     "gray44"
+     "grey43"
+     "gray43"
+     "grey42"
+     "gray42"
+     "grey41"
+     "gray41"
+     "grey40"
+     "gray40"
+     "grey39"
+     "gray39"
+     "grey38"
+     "gray38"
+     "grey37"
+     "gray37"
+     "grey36"
+     "gray36"
+     "grey35"
+     "gray35"
+     "grey34"
+     "gray34"
+     "grey33"
+     "gray33"
+     "grey32"
+     "gray32"
+     "grey31"
+     "gray31"
+     "grey30"
+     "gray30"
+     "grey29"
+     "gray29"
+     "grey28"
+     "gray28"
+     "grey27"
+     "gray27"
+     "grey26"
+     "gray26"
+     "grey25"
+     "gray25"
+     "grey24"
+     "gray24"
+     "grey23"
+     "gray23"
+     "grey22"
+     "gray22"
+     "grey21"
+     "gray21"
+     "grey20"
+     "gray20"
+     "grey19"
+     "gray19"
+     "grey18"
+     "gray18"
+     "grey17"
+     "gray17"
+     "grey16"
+     "gray16"
+     "grey15"
+     "gray15"
+     "grey14"
+     "gray14"
+     "grey13"
+     "gray13"
+     "grey12"
+     "gray12"
+     "grey11"
+     "gray11"
+     "grey10"
+     "gray10"
+     "grey9"
+     "gray9"
+     "grey8"
+     "gray8"
+     "grey7"
+     "gray7"
+     "grey6"
+     "gray6"
+     "grey5"
+     "gray5"
+     "grey4"
+     "gray4"
+     "grey3"
+     "gray3"
+     "grey2"
+     "gray2"
+     "grey1"
+     "gray1"
+     "grey0"
+     "gray0"
+     "thistle4"
+     "thistle3"
+     "thistle2"
+     "thistle1"
+     "MediumPurple4"
+     "MediumPurple3"
+     "MediumPurple2"
+     "MediumPurple1"
+     "purple4"
+     "purple3"
+     "purple2"
+     "purple1"
+     "DarkOrchid4"
+     "DarkOrchid3"
+     "DarkOrchid2"
+     "DarkOrchid1"
+     "MediumOrchid4"
+     "MediumOrchid3"
+     "MediumOrchid2"
+     "MediumOrchid1"
+     "plum4"
+     "plum3"
+     "plum2"
+     "plum1"
+     "orchid4"
+     "orchid3"
+     "orchid2"
+     "orchid1"
+     "magenta4"
+     "magenta3"
+     "magenta2"
+     "magenta1"
+     "VioletRed4"
+     "VioletRed3"
+     "VioletRed2"
+     "VioletRed1"
+     "maroon4"
+     "maroon3"
+     "maroon2"
+     "maroon1"
+     "PaleVioletRed4"
+     "PaleVioletRed3"
+     "PaleVioletRed2"
+     "PaleVioletRed1"
+     "LightPink4"
+     "LightPink3"
+     "LightPink2"
+     "LightPink1"
+     "pink4"
+     "pink3"
+     "pink2"
+     "pink1"
+     "HotPink4"
+     "HotPink3"
+     "HotPink2"
+     "HotPink1"
+     "DeepPink4"
+     "DeepPink3"
+     "DeepPink2"
+     "DeepPink1"
+     "red4"
+     "red3"
+     "red2"
+     "red1"
+     "OrangeRed4"
+     "OrangeRed3"
+     "OrangeRed2"
+     "OrangeRed1"
+     "tomato4"
+     "tomato3"
+     "tomato2"
+     "tomato1"
+     "coral4"
+     "coral3"
+     "coral2"
+     "coral1"
+     "DarkOrange4"
+     "DarkOrange3"
+     "DarkOrange2"
+     "DarkOrange1"
+     "orange4"
+     "orange3"
+     "orange2"
+     "orange1"
+     "LightSalmon4"
+     "LightSalmon3"
+     "LightSalmon2"
+     "LightSalmon1"
+     "salmon4"
+     "salmon3"
+     "salmon2"
+     "salmon1"
+     "brown4"
+     "brown3"
+     "brown2"
+     "brown1"
+     "firebrick4"
+     "firebrick3"
+     "firebrick2"
+     "firebrick1"
+     "chocolate4"
+     "chocolate3"
+     "chocolate2"
+     "chocolate1"
+     "tan4"
+     "tan3"
+     "tan2"
+     "tan1"
+     "wheat4"
+     "wheat3"
+     "wheat2"
+     "wheat1"
+     "burlywood4"
+     "burlywood3"
+     "burlywood2"
+     "burlywood1"
+     "sienna4"
+     "sienna3"
+     "sienna2"
+     "sienna1"
+     "IndianRed4"
+     "IndianRed3"
+     "IndianRed2"
+     "IndianRed1"
+     "RosyBrown4"
+     "RosyBrown3"
+     "RosyBrown2"
+     "RosyBrown1"
+     "DarkGoldenrod4"
+     "DarkGoldenrod3"
+     "DarkGoldenrod2"
+     "DarkGoldenrod1"
+     "goldenrod4"
+     "goldenrod3"
+     "goldenrod2"
+     "goldenrod1"
+     "gold4"
+     "gold3"
+     "gold2"
+     "gold1"
+     "yellow4"
+     "yellow3"
+     "yellow2"
+     "yellow1"
+     "LightYellow4"
+     "LightYellow3"
+     "LightYellow2"
+     "LightYellow1"
+     "LightGoldenrod4"
+     "LightGoldenrod3"
+     "LightGoldenrod2"
+     "LightGoldenrod1"
+     "khaki4"
+     "khaki3"
+     "khaki2"
+     "khaki1"
+     "DarkOliveGreen4"
+     "DarkOliveGreen3"
+     "DarkOliveGreen2"
+     "DarkOliveGreen1"
+     "OliveDrab4"
+     "OliveDrab3"
+     "OliveDrab2"
+     "OliveDrab1"
+     "chartreuse4"
+     "chartreuse3"
+     "chartreuse2"
+     "chartreuse1"
+     "green4"
+     "green3"
+     "green2"
+     "green1"
+     "SpringGreen4"
+     "SpringGreen3"
+     "SpringGreen2"
+     "SpringGreen1"
+     "PaleGreen4"
+     "PaleGreen3"
+     "PaleGreen2"
+     "PaleGreen1"
+     "SeaGreen4"
+     "SeaGreen3"
+     "SeaGreen2"
+     "SeaGreen1"
+     "DarkSeaGreen4"
+     "DarkSeaGreen3"
+     "DarkSeaGreen2"
+     "DarkSeaGreen1"
+     "aquamarine4"
+     "aquamarine3"
+     "aquamarine2"
+     "aquamarine1"
+     "DarkSlateGray4"
+     "DarkSlateGray3"
+     "DarkSlateGray2"
+     "DarkSlateGray1"
+     "cyan4"
+     "cyan3"
+     "cyan2"
+     "cyan1"
+     "turquoise4"
+     "turquoise3"
+     "turquoise2"
+     "turquoise1"
+     "CadetBlue4"
+     "CadetBlue3"
+     "CadetBlue2"
+     "CadetBlue1"
+     "PaleTurquoise4"
+     "PaleTurquoise3"
+     "PaleTurquoise2"
+     "PaleTurquoise1"
+     "LightCyan4"
+     "LightCyan3"
+     "LightCyan2"
+     "LightCyan1"
+     "LightBlue4"
+     "LightBlue3"
+     "LightBlue2"
+     "LightBlue1"
+     "LightSteelBlue4"
+     "LightSteelBlue3"
+     "LightSteelBlue2"
+     "LightSteelBlue1"
+     "SlateGray4"
+     "SlateGray3"
+     "SlateGray2"
+     "SlateGray1"
+     "LightSkyBlue4"
+     "LightSkyBlue3"
+     "LightSkyBlue2"
+     "LightSkyBlue1"
+     "SkyBlue4"
+     "SkyBlue3"
+     "SkyBlue2"
+     "SkyBlue1"
+     "DeepSkyBlue4"
+     "DeepSkyBlue3"
+     "DeepSkyBlue2"
+     "DeepSkyBlue1"
+     "SteelBlue4"
+     "SteelBlue3"
+     "SteelBlue2"
+     "SteelBlue1"
+     "DodgerBlue4"
+     "DodgerBlue3"
+     "DodgerBlue2"
+     "DodgerBlue1"
+     "blue4"
+     "blue3"
+     "blue2"
+     "blue1"
+     "RoyalBlue4"
+     "RoyalBlue3"
+     "RoyalBlue2"
+     "RoyalBlue1"
+     "SlateBlue4"
+     "SlateBlue3"
+     "SlateBlue2"
+     "SlateBlue1"
+     "azure4"
+     "azure3"
+     "azure2"
+     "azure1"
+     "MistyRose4"
+     "MistyRose3"
+     "MistyRose2"
+     "MistyRose1"
+     "LavenderBlush4"
+     "LavenderBlush3"
+     "LavenderBlush2"
+     "LavenderBlush1"
+     "honeydew4"
+     "honeydew3"
+     "honeydew2"
+     "honeydew1"
+     "ivory4"
+     "ivory3"
+     "ivory2"
+     "ivory1"
+     "cornsilk4"
+     "cornsilk3"
+     "cornsilk2"
+     "cornsilk1"
+     "LemonChiffon4"
+     "LemonChiffon3"
+     "LemonChiffon2"
+     "LemonChiffon1"
+     "NavajoWhite4"
+     "NavajoWhite3"
+     "NavajoWhite2"
+     "NavajoWhite1"
+     "PeachPuff4"
+     "PeachPuff3"
+     "PeachPuff2"
+     "PeachPuff1"
+     "bisque4"
+     "bisque3"
+     "bisque2"
+     "bisque1"
+     "AntiqueWhite4"
+     "AntiqueWhite3"
+     "AntiqueWhite2"
+     "AntiqueWhite1"
+     "seashell4"
+     "seashell3"
+     "seashell2"
+     "seashell1"
+     "snow4"
+     "snow3"
+     "snow2"
+     "snow1"
+     "thistle"
+     "MediumPurple"
+     "medium purple"
+     "purple"
+     "BlueViolet"
+     "blue violet"
+     "DarkViolet"
+     "dark violet"
+     "DarkOrchid"
+     "dark orchid"
+     "MediumOrchid"
+     "medium orchid"
+     "orchid"
+     "plum"
+     "violet"
+     "magenta"
+     "VioletRed"
+     "violet red"
+     "MediumVioletRed"
+     "medium violet red"
+     "maroon"
+     "PaleVioletRed"
+     "pale violet red"
+     "LightPink"
+     "light pink"
+     "pink"
+     "DeepPink"
+     "deep pink"
+     "HotPink"
+     "hot pink"
+     "red"
+     "OrangeRed"
+     "orange red"
+     "tomato"
+     "LightCoral"
+     "light coral"
+     "coral"
+     "DarkOrange"
+     "dark orange"
+     "orange"
+     "LightSalmon"
+     "light salmon"
+     "salmon"
+     "DarkSalmon"
+     "dark salmon"
+     "brown"
+     "firebrick"
+     "chocolate"
+     "tan"
+     "SandyBrown"
+     "sandy brown"
+     "wheat"
+     "beige"
+     "burlywood"
+     "peru"
+     "sienna"
+     "SaddleBrown"
+     "saddle brown"
+     "IndianRed"
+     "indian red"
+     "RosyBrown"
+     "rosy brown"
+     "DarkGoldenrod"
+     "dark goldenrod"
+     "goldenrod"
+     "LightGoldenrod"
+     "light goldenrod"
+     "gold"
+     "yellow"
+     "LightYellow"
+     "light yellow"
+     "LightGoldenrodYellow"
+     "light goldenrod yellow"
+     "PaleGoldenrod"
+     "pale goldenrod"
+     "khaki"
+     "DarkKhaki"
+     "dark khaki"
+     "OliveDrab"
+     "olive drab"
+     "ForestGreen"
+     "forest green"
+     "YellowGreen"
+     "yellow green"
+     "LimeGreen"
+     "lime green"
+     "GreenYellow"
+     "green yellow"
+     "MediumSpringGreen"
+     "medium spring green"
+     "chartreuse"
+     "green"
+     "LawnGreen"
+     "lawn green"
+     "SpringGreen"
+     "spring green"
+     "PaleGreen"
+     "pale green"
+     "LightSeaGreen"
+     "light sea green"
+     "MediumSeaGreen"
+     "medium sea green"
+     "SeaGreen"
+     "sea green"
+     "DarkSeaGreen"
+     "dark sea green"
+     "DarkOliveGreen"
+     "dark olive green"
+     "DarkGreen"
+     "dark green"
+     "aquamarine"
+     "MediumAquamarine"
+     "medium aquamarine"
+     "CadetBlue"
+     "cadet blue"
+     "LightCyan"
+     "light cyan"
+     "cyan"
+     "turquoise"
+     "MediumTurquoise"
+     "medium turquoise"
+     "DarkTurquoise"
+     "dark turquoise"
+     "PaleTurquoise"
+     "pale turquoise"
+     "PowderBlue"
+     "powder blue"
+     "LightBlue"
+     "light blue"
+     "LightSteelBlue"
+     "light steel blue"
+     "SteelBlue"
+     "steel blue"
+     "LightSkyBlue"
+     "light sky blue"
+     "SkyBlue"
+     "sky blue"
+     "DeepSkyBlue"
+     "deep sky blue"
+     "DodgerBlue"
+     "dodger blue"
+     "blue"
+     "RoyalBlue"
+     "royal blue"
+     "MediumBlue"
+     "medium blue"
+     "LightSlateBlue"
+     "light slate blue"
+     "MediumSlateBlue"
+     "medium slate blue"
+     "SlateBlue"
+     "slate blue"
+     "DarkSlateBlue"
+     "dark slate blue"
+     "CornflowerBlue"
+     "cornflower blue"
+     "NavyBlue"
+     "navy blue"
+     "navy"
+     "MidnightBlue"
+     "midnight blue"
+     "LightGray"
+     "light gray"
+     "LightGrey"
+     "light grey"
+     "grey"
+     "gray"
+     "LightSlateGrey"
+     "light slate grey"
+     "LightSlateGray"
+     "light slate gray"
+     "SlateGrey"
+     "slate grey"
+     "SlateGray"
+     "slate gray"
+     "DimGrey"
+     "dim grey"
+     "DimGray"
+     "dim gray"
+     "DarkSlateGrey"
+     "dark slate grey"
+     "DarkSlateGray"
+     "dark slate gray"
+     "black"
+     "white"
+     "MistyRose"
+     "misty rose"
+     "LavenderBlush"
+     "lavender blush"
+     "lavender"
+     "AliceBlue"
+     "alice blue"
+     "azure"
+     "MintCream"
+     "mint cream"
+     "honeydew"
+     "seashell"
+     "LemonChiffon"
+     "lemon chiffon"
+     "ivory"
+     "cornsilk"
+     "moccasin"
+     "NavajoWhite"
+     "navajo white"
+     "PeachPuff"
+     "peach puff"
+     "bisque"
+     "BlanchedAlmond"
+     "blanched almond"
+     "PapayaWhip"
+     "papaya whip"
+     "AntiqueWhite"
+     "antique white"
+     "linen"
+     "OldLace"
+     "old lace"
+     "FloralWhite"
+     "floral white"
+     "gainsboro"
+     "WhiteSmoke"
+     "white smoke"
+     "GhostWhite"
+     "ghost white"
+     "snow"))
   "List of basic colors available on color displays.
 For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
 For Nextstep, this is a list of non-PANTONE colors returned by

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 16:33     ` Juri Linkov
@ 2010-06-04 17:01       ` Eli Zaretskii
  0 siblings, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2010-06-04 17:01 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

> From: Juri Linkov <juri@jurta.org>
> Cc: 6332@debbugs.gnu.org
> Date: Fri, 04 Jun 2010 19:33:28 +0300
> 
> > Can you show the differences between the list before and after the
> > change you suggest?  Can someone else please do that on MS-Windows?
> 
> === modified file 'lisp/term/common-win.el'
> --- lisp/term/common-win.el	2010-01-13 08:35:10 +0000
> +++ lisp/term/common-win.el	2010-06-04 16:23:12 +0000

I asked to see the differences between the lists of colors produced by
list-colors-display in both cases, not to see the diffs between two
versions of source code.

However, given Yidong's objection, I guess this is a moot point.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 16:19   ` Juri Linkov
@ 2010-06-04 17:26     ` Juanma Barranquero
  2010-06-04 18:03       ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Juanma Barranquero @ 2010-06-04 17:26 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

On Fri, Jun 4, 2010 at 18:19, Juri Linkov <juri@jurta.org> wrote:

> This is ok, `list-colors-display' already removes duplicated color names
> with the help of `list-colors-duplicates'.

That's not my point. My point is: with the change, did you lose any
color definition, or just the name you were using for that color?

    Juanma





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 17:26     ` Juanma Barranquero
@ 2010-06-04 18:03       ` Juri Linkov
  2010-06-04 19:02         ` Juanma Barranquero
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 18:03 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 6332

>> This is ok, `list-colors-display' already removes duplicated color names
>> with the help of `list-colors-duplicates'.
>
> That's not my point. My point is: with the change, did you lose any
> color definition, or just the name you were using for that color?

Not to lose color definitions, but to add all missing ones that are
in rgb.txt.  `list-colors-duplicates' takes care of colors with same
RGB triplets, thus `list-colors-display' will contain 548 lines
for 752 names of colors in rgb.txt (like it was already in Emacs 22).

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 18:03       ` Juri Linkov
@ 2010-06-04 19:02         ` Juanma Barranquero
  2010-06-04 19:41           ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Juanma Barranquero @ 2010-06-04 19:02 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

On Fri, Jun 4, 2010 at 20:03, Juri Linkov <juri@jurta.org> wrote:

> Not to lose color definitions, but to add all missing ones that are
> in rgb.txt.

Apparently, there were just two colors missing...

    Juanma





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 19:02         ` Juanma Barranquero
@ 2010-06-04 19:41           ` Juri Linkov
  2010-06-04 19:54             ` Juanma Barranquero
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 19:41 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 6332

>> Not to lose color definitions, but to add all missing ones that are
>> in rgb.txt.
>
> Apparently, there were just two colors missing...

"DarkGreen", "dark green", "DarkTurquoise", "dark turquoise",
all variants of gray/grey since currently there is a complete mess
with some colors having only "gray" and other only "grey", e.g.:

dim gray
dark grey
gray
light grey

Please, please return all colors that always were in x-colors
since `list-colors-display' does the right thing with them.

After that we could add any sorting order as one of options,
and set it as the default.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 19:41           ` Juri Linkov
@ 2010-06-04 19:54             ` Juanma Barranquero
  2010-06-04 19:57               ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Juanma Barranquero @ 2010-06-04 19:54 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

On Fri, Jun 4, 2010 at 21:41, Juri Linkov <juri@jurta.org> wrote:

> "DarkGreen", "dark green", "DarkTurquoise", "dark turquoise",
> all variants of gray/grey since currently there is a complete mess
> with some colors having only "gray" and other only "grey", e.g.:

So you're not talking about colors, just color names; they aren't
different colors more than "red", "rojo", "rosso" and "rouge" are.

    Juanma





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-04 19:54             ` Juanma Barranquero
@ 2010-06-04 19:57               ` Juri Linkov
  0 siblings, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2010-06-04 19:57 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 6332

> So you're not talking about colors, just color names; they aren't
> different colors more than "red", "rojo", "rosso" and "rouge" are.

I'm talking about colors and color names.  `list-colors-display'
already can group color names by colors - it displays all color names
on one color line.  So the *Colors* buffer contains one line per color
with all its color names on the same line separated by comma.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-02 19:38 bug#6332: Colors lost from list-colors-display Juri Linkov
  2010-06-03 19:31 ` Juri Linkov
  2010-06-04 10:48 ` Juanma Barranquero
@ 2010-06-12 17:13 ` Chong Yidong
  2010-06-12 20:05   ` Juri Linkov
  2 siblings, 1 reply; 21+ messages in thread
From: Chong Yidong @ 2010-06-12 17:13 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332-done

I have added all 752 rgb.txt colors to `x-colors'.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-12 17:13 ` Chong Yidong
@ 2010-06-12 20:05   ` Juri Linkov
  2010-06-12 22:14     ` Chong Yidong
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-12 20:05 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 6332

> I have added all 752 rgb.txt colors to `x-colors'.

Thank you!

I could now install the patch that adds the sorting option.  OK?

=== modified file 'lisp/facemenu.el'
--- lisp/facemenu.el	2010-06-12 19:52:17 +0000
+++ lisp/facemenu.el	2010-06-12 19:54:57 +0000
@@ -479,6 +479,71 @@ (defun facemenu-read-color (&optional pr
 	nil
       col)))
 
+(defun color-rgb-to-hsv (r g b)
+  "For R, G, B color components return a list of hue, saturation, value.
+R, G, B input values should be in [0..65535] range.
+Output values for hue are in [0..360] range.
+Output values for saturation and value are in [0..1] range."
+  (let* ((r (/ r 65535.0))
+	 (g (/ g 65535.0))
+	 (b (/ b 65535.0))
+	 (max (max r g b))
+	 (min (min r g b))
+	 (h (cond ((= max min) 0)
+		  ((= max r) (mod (+ (* 60 (/ (- g b) (- max min))) 360) 360))
+		  ((= max g) (+ (* 60 (/ (- b r) (- max min))) 120))
+		  ((= max b) (+ (* 60 (/ (- r g) (- max min))) 240))))
+	 (s (cond ((= max 0) 0)
+		  (t (- 1 (/ min max)))))
+	 (v max))
+    (list h s v)))
+
+(defcustom list-colors-sort nil
+  "Sort order for `list-colors-display'.
+`nil' means default implementation-dependent order (defined in `x-colors').
+`name' sorts by color name.
+`r-g-b' sorts by red, green, blue components.
+`h-s-v' sorts by hue, saturation, value.
+`hsv-dist' sorts by the HVS distance to the specified color."
+  :type '(choice (const :tag "Color Name" name)
+		 (const :tag "Red-Green-Blue" r-g-b)
+		 (cons :tag "Distance on RGB cube"
+		       (const :tag "Distance from Color" rgb-dist)
+		       (color :tag "Source Color Name"))
+		 (const :tag "Hue-Saturation-Value" h-s-v)
+		 (cons :tag "Distance on HSV cylinder"
+		       (const :tag "Distance from Color" hsv-dist)
+		       (color :tag "Source Color Name"))
+		 (const :tag "Unsorted" nil))
+  :group 'facemenu
+  :version "24.1")
+
+(defun list-colors-sort-key (color)
+  "Return a list of keys for sorting colors depending on `list-colors-sort'.
+COLOR is the name of the color.  Filters out a color from the output
+when return value is nil."
+  (cond
+   ((null list-colors-sort) color)
+   ((eq list-colors-sort 'name)
+    color)
+   ((eq list-colors-sort 'r-g-b)
+    (color-values color))
+   ((eq (car-safe list-colors-sort) 'rgb-dist)
+    (color-distance color (cdr list-colors-sort)))
+   ((eq list-colors-sort 'h-s-v)
+    (apply 'color-rgb-to-hsv (color-values color)))
+   ((eq (car-safe list-colors-sort) 'hsv-dist)
+    (let* ((c-rgb (color-values color))
+	   (c-hsv (apply 'color-rgb-to-hsv c-rgb))
+	   (o-hsv (apply 'color-rgb-to-hsv
+			 (color-values (cdr list-colors-sort)))))
+      (unless (and (eq (nth 0 c-rgb) (nth 1 c-rgb)) ; exclude grayscale
+		   (eq (nth 1 c-rgb) (nth 2 c-rgb)))
+	;; 3D Euclidean distance (sqrt is not needed for sorting)
+	(+ (expt (- 180 (abs (- 180 (abs (- (nth 0 c-hsv) ; wrap hue
+					    (nth 0 o-hsv)))))) 2)
+	   (expt (- (nth 1 c-hsv) (nth 1 o-hsv)) 2)
+	   (expt (- (nth 2 c-hsv) (nth 2 o-hsv)) 2)))))))
 
 (defun list-colors-display (&optional list buffer-name callback)
   "Display names of defined colors, and show what they look like.
@@ -496,6 +561,30 @@ (defun list-colors-display (&optional li
   (interactive)
   (when (and (null list) (> (display-color-cells) 0))
     (setq list (list-colors-duplicates (defined-colors)))
+    (when list-colors-sort
+      (setq list (mapcar
+		  'car
+		  (sort (delq nil (mapcar
+				   (lambda (c)
+				     (let ((key (list-colors-sort-key
+						 (car c))))
+				       (when key
+					 (cons c (if (consp key) key
+						   (list key))))))
+				   list))
+			(lambda (a b)
+			  (let* ((a-keys (cdr a))
+				 (b-keys (cdr b))
+				 (a-key (car a-keys))
+				 (b-key (car b-keys)))
+			    (while (and a-key b-key (eq a-key b-key))
+			      (setq a-keys (cdr a-keys) a-key (car a-keys)
+				    b-keys (cdr b-keys) b-key (car b-keys)))
+			    (cond
+			     ((and (numberp a-key) (numberp b-key))
+			      (< a-key b-key))
+			     ((and (stringp a-key) (stringp b-key))
+			      (string< a-key b-key)))))))))
     (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color))
       ;; Don't show more than what the display can handle.
       (let ((lc (nthcdr (1- (display-color-cells)) list)))

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-12 20:05   ` Juri Linkov
@ 2010-06-12 22:14     ` Chong Yidong
  2010-06-14 16:12       ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Chong Yidong @ 2010-06-12 22:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 6332

Juri Linkov <juri@jurta.org> writes:

> I could now install the patch that adds the sorting option.  OK?

I don't mind.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-12 22:14     ` Chong Yidong
@ 2010-06-14 16:12       ` Juri Linkov
  2010-06-14 19:10         ` Stefan Monnier
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2010-06-14 16:12 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 6332

>> I could now install the patch that adds the sorting option.  OK?
>
> I don't mind.

Committed.

I found another problem in `list-colors-display':
on a wide frame it uses a wrong value of `window-width'
because `list-colors-print' generates the color list
before it's displayed that might split the frame horizontally.

The following patch fixes this problem by displaying the output buffer
before generating its content (that is very fast thus there is no delay
and no bad visual effects):

Using parent branch file:///home/work/emacs/bzr/emacs/http-trunk/
=== modified file 'lisp/facemenu.el'
--- lisp/facemenu.el	2010-06-14 16:03:04 +0000
+++ lisp/facemenu.el	2010-06-14 16:11:18 +0000
@@ -600,9 +600,11 @@ (defun list-colors-display (&optional li
     (with-current-buffer buf
       (erase-buffer)
       (setq truncate-lines t)
+      ;; Display buffer before generating content to allow
+      ;; list-colors-print to get the right window-width.
+      (pop-to-buffer buf)
       (list-colors-print list callback)
-      (set-buffer-modified-p nil))
-    (pop-to-buffer buf))
+      (set-buffer-modified-p nil)))
   (if callback
       (message "Click on a color to select it.")))

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-14 16:12       ` Juri Linkov
@ 2010-06-14 19:10         ` Stefan Monnier
  2010-06-16 21:41           ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Monnier @ 2010-06-14 19:10 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Chong Yidong, 6332

> I found another problem in `list-colors-display':
> on a wide frame it uses a wrong value of `window-width'
> because `list-colors-print' generates the color list
> before it's displayed that might split the frame horizontally.

A common problem.

> The following patch fixes this problem by displaying the output buffer
> before generating its content (that is very fast thus there is no delay
> and no bad visual effects):

Thanks, that's a good change.


        Stefan





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#6332: Colors lost from list-colors-display
  2010-06-14 19:10         ` Stefan Monnier
@ 2010-06-16 21:41           ` Juri Linkov
  0 siblings, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2010-06-16 21:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Chong Yidong, 6332

>> I found another problem in `list-colors-display':
>> on a wide frame it uses a wrong value of `window-width'
>> because `list-colors-print' generates the color list
>> before it's displayed that might split the frame horizontally.
>
> A common problem.

Currently this problem is most annoying in `M-x man'.
I'll try to finish bug#5054 for handling asynchronous man.

>> The following patch fixes this problem by displaying the output buffer
>> before generating its content (that is very fast thus there is no delay
>> and no bad visual effects):
>
> Thanks, that's a good change.

Committed.

-- 
Juri Linkov
http://www.jurta.org/emacs/





^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-06-16 21:41 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 19:38 bug#6332: Colors lost from list-colors-display Juri Linkov
2010-06-03 19:31 ` Juri Linkov
2010-06-04  8:42   ` Eli Zaretskii
2010-06-04 16:33     ` Juri Linkov
2010-06-04 17:01       ` Eli Zaretskii
2010-06-04 16:07   ` Chong Yidong
2010-06-04 16:20     ` Juri Linkov
2010-06-04 10:48 ` Juanma Barranquero
2010-06-04 16:19   ` Juri Linkov
2010-06-04 17:26     ` Juanma Barranquero
2010-06-04 18:03       ` Juri Linkov
2010-06-04 19:02         ` Juanma Barranquero
2010-06-04 19:41           ` Juri Linkov
2010-06-04 19:54             ` Juanma Barranquero
2010-06-04 19:57               ` Juri Linkov
2010-06-12 17:13 ` Chong Yidong
2010-06-12 20:05   ` Juri Linkov
2010-06-12 22:14     ` Chong Yidong
2010-06-14 16:12       ` Juri Linkov
2010-06-14 19:10         ` Stefan Monnier
2010-06-16 21:41           ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).