emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch to display "System" colors


From: Michael Mauger
Subject: Re: Patch to display "System" colors
Date: Mon, 17 Nov 2003 17:10:30 -0800 (PST)

--- Jason Rumney <address@hidden> wrote:
> "Eli Zaretskii" <address@hidden> writes:
> > > From: Jason Rumney <address@hidden>
> > > Date: 15 Nov 2003 14:28:16 +0000
> > > 
> > > I think the idea is to let users know that these exist so they can
> > > use them in their own customizations. The other duplicates that are
> > > suppressed are spelling variations, so it is not important to show
> > > all of those in list-colors-display.
> > 
> > Then perhaps we should modify the code that rejects colors so that it
> > only rejects based on spelling, not on pixel values.
> 
> It might be enough to remove spaces, downcase and standardize
> gray/grey before doing the comparison.
> 

Here's a patch that normalizes the color names as Jason suggests.  Use
this in place of my original patch.  This does not look at the color
values at all.

Is there an existing elisp function to replace substrings within an
original string with replacement substrings?  See
`facemenu-string-match-and-replace' in the patch below.

Index: emacs/lisp/facemenu.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/facemenu.el,v
retrieving revision 1.71
diff -u -b -r1.71 facemenu.el
--- emacs/lisp/facemenu.el      1 Sep 2003 15:45:11 -0000       1.71
+++ emacs/lisp/facemenu.el      18 Nov 2003 00:57:51 -0000
@@ -512,5 +514,25 @@
 This function queries the display system to find out what the color
 names mean.  It returns nil if the colors differ or if it can't
 determine the correct answer."
-  (cond ((equal a b) t)
-       ((equal (color-values a) (color-values b)))))
+  (progn
+    (setq a (facemenu-string-match-and-replace
+            (facemenu-string-match-and-replace
+             (downcase a)              ; downcase
+             " " "")                   ; remove spaces
+            "grey" "gray")             ; translate `grey' to `gray'
+         b (facemenu-string-match-and-replace
+            (facemenu-string-match-and-replace
+             (downcase b)
+             " " "")
+            "grey" "gray"))
+
+    (equal a b)))
+
+(defun facemenu-string-match-and-replace (str from to)
+  "Return the string STR with all occurences of the regular
+expression FROM replaced by TO."
+  (while (string-match from str)
+    (setq str (concat (substring str 0 (match-beginning 0))
+                     to
+                     (substring str (match-end 0)))))
+  str)

 (defun facemenu-add-face (face &optional start end)
   "Add FACE to text between START and END.


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree




reply via email to

[Prev in Thread] Current Thread [Next in Thread]