]> git.eshelyaron.com Git - emacs.git/commitdiff
(facemenu-color-name-equal): New function.
authorEli Zaretskii <eliz@gnu.org>
Thu, 20 May 2004 16:59:22 +0000 (16:59 +0000)
committerEli Zaretskii <eliz@gnu.org>
Thu, 20 May 2004 16:59:22 +0000 (16:59 +0000)
(list-colors-display): Use it to compare colors instead of
facemenu-color-equal.

lisp/ChangeLog
lisp/facemenu.el

index c0b9b0100dd34e53ae27ec9c0c2af05b01b3bc27..a6271544405aa23a060dfcb72530910e20dd76ad 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-20  Michael Mauger  <mmaug@yahoo.com>
+
+       * facemenu.el (facemenu-color-name-equal): New function.
+       (list-colors-display): Use it to compare colors instead of
+       facemenu-color-equal.
+
 2004-05-20  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * compare-w.el (compare-windows-face): Use min-colors instead of
index 3893e320655e32a48c41f33f1c7c5516653a3972..e9af58fc73db9285ea44d2346b280d37d8196114 100644 (file)
@@ -480,9 +480,19 @@ of colors that the current display can handle."
   (when (and (null list) (> (display-color-cells) 0))
     (setq list (defined-colors))
     ;; Delete duplicate colors.
+
+    ;; Identify duplicate colors by the name rather than the color
+    ;; value.  For example, on MS-Windows, logical colors are added to
+    ;; the list that might have the same value but have different
+    ;; names and meanings.  For example, `SystemMenuText' (the color
+    ;; w32 uses for the text in menu entries) and `SystemWindowText'
+    ;; (the default color w32 uses for the text in windows and
+    ;; dialogs) may be the same display color and be adjacent in the
+    ;; list.  Detecting duplicates by name insures that both of these
+    ;; colors remain despite identical color values.
     (let ((l list))
       (while (cdr l)
-       (if (facemenu-color-equal (car l) (car (cdr l)))
+       (if (facemenu-color-name-equal (car l) (car (cdr l)))
            (setcdr l (cdr (cdr l)))
          (setq l (cdr l)))))
     (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color))
@@ -515,6 +525,22 @@ determine the correct answer."
   (cond ((equal a b) t)
        ((equal (color-values a) (color-values b)))))
 
+(defun facemenu-color-name-equal (a b)
+  "Return t if colors A and B are the same color.
+A and B should be strings naming colors.  These names are
+downcased, stripped of spaces and the string `grey' is turned
+into `gray'.  This accommodates alternative spellings of colors
+found commonly in the list.  It returns nil if the colors differ."
+  (progn
+    (setq a (replace-regexp-in-string "grey" "gray"
+            (replace-regexp-in-string " " ""
+             (downcase a)))
+         b (replace-regexp-in-string "grey" "gray"
+            (replace-regexp-in-string " " ""
+             (downcase b))))
+
+    (equal a b)))
+
 (defun facemenu-add-face (face &optional start end)
   "Add FACE to text between START and END.
 If START is nil or START to END is empty, add FACE to next typed character