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: list-colors-display: filter same adjecent colors Date: Mon, 5 Apr 2004 20:08:29 -0700 (PDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040406030829.11987.qmail@web60307.mail.yahoo.com> References: <7137-Sat06Mar2004105150+0200-eliz@elta.co.il> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1081221472 32516 80.91.224.253 (6 Apr 2004 03:17:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 6 Apr 2004 03:17:52 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Apr 06 05:17:46 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BAh5u-0003u7-00 for ; Tue, 06 Apr 2004 05:17:46 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BAh5t-0005jZ-00 for ; Tue, 06 Apr 2004 05:17:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BAh4Y-0005LF-JV for emacs-devel@quimby.gnus.org; Mon, 05 Apr 2004 23:16:22 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BAh3v-0005K6-1k for emacs-devel@gnu.org; Mon, 05 Apr 2004 23:15:43 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BAh3O-0005Bg-38 for emacs-devel@gnu.org; Mon, 05 Apr 2004 23:15:42 -0400 Original-Received: from [216.109.118.118] (helo=web60307.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.30) id 1BAh3N-0005BP-Ri for emacs-devel@gnu.org; Mon, 05 Apr 2004 23:15:09 -0400 Original-Received: from [12.76.166.173] by web60307.mail.yahoo.com via HTTP; Mon, 05 Apr 2004 20:08:29 PDT Original-To: Eli Zaretskii In-Reply-To: <7137-Sat06Mar2004105150+0200-eliz@elta.co.il> X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 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:21293 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21293 Sorry for the delay on this -- I've been offline for a bit. How does this version (with an expanded comment block) look? Index: emacs/lisp/facemenu.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/facemenu.el,v retrieving revision 1.71 diff -u -r1.71 facemenu.el --- emacs/lisp/facemenu.el 1 Sep 2003 15:45:11 -0000 1.71 +++ emacs/lisp/facemenu.el 13 Mar 2004 21:59:20 -0000 @@ -480,9 +480,19 @@ (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. On w32, logical colors are added to the list that might + ;; have the same value but have different names and meanings. For + ;; eaxmple, `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 similar 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)) @@ -514,6 +524,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 accomidates 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. --- Eli Zaretskii wrote: > > Date: Fri, 5 Mar 2004 15:49:19 -0800 (PST) > > From: Michael Mauger > > > > How does this patch look: > > It's okay with me, but I'd suggest to give an explicit example in > this comment: > > > + ;; Identify duplicate colors by the name rather than the color > > + ;; value. On w32, logical colors are added to the list that > might > > + ;; have the same value but have different names and meanings. > > + ;; Detecting duplicates by name insures that all of these > logical > > + ;; colors remain despite similar color values. > > I'd mention the special ``system'' colors and why they are important, > just so people could see a specific example. > > Thanks. __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/