From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Michael Mauger Newsgroups: gmane.emacs.devel Subject: Re: Patch to display "System" colors Date: Mon, 17 Nov 2003 17:10:30 -0800 (PST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20031118011030.39549.qmail@web60307.mail.yahoo.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1069118042 8795 80.91.224.253 (18 Nov 2003 01:14:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Nov 2003 01:14:02 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Nov 18 02:13:58 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ALuRK-0000Ar-00 for ; Tue, 18 Nov 2003 02:13:58 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ALuRJ-0000Qx-00 for ; Tue, 18 Nov 2003 02:13:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ALvOM-0005Js-L7 for emacs-devel@quimby.gnus.org; Mon, 17 Nov 2003 21:14:58 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ALvMT-00038X-C9 for emacs-devel@gnu.org; Mon, 17 Nov 2003 21:13:01 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ALvLV-0001WQ-Gr for emacs-devel@gnu.org; Mon, 17 Nov 2003 21:12:32 -0500 Original-Received: from [216.109.118.118] (helo=web60307.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.24) id 1ALvLQ-0001LV-Q8 for emacs-devel@gnu.org; Mon, 17 Nov 2003 21:11:56 -0500 Original-Received: from [12.91.2.181] by web60307.mail.yahoo.com via HTTP; Mon, 17 Nov 2003 17:10:30 PST Original-To: Jason Rumney , Eli Zaretskii In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17873 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17873 --- Jason Rumney wrote: > "Eli Zaretskii" writes: > > > From: Jason Rumney > > > 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