diff options
| author | Eli Zaretskii | 2004-05-20 16:59:22 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2004-05-20 16:59:22 +0000 |
| commit | 64867fce6d1b4b041d0e8fc9634ba1b6d2f026ba (patch) | |
| tree | 5857c7f6c44eacc44d20265605c44bea517f5c57 | |
| parent | 88537a99d684a40aeaf960a277447caf575d689a (diff) | |
| download | emacs-64867fce6d1b4b041d0e8fc9634ba1b6d2f026ba.tar.gz emacs-64867fce6d1b4b041d0e8fc9634ba1b6d2f026ba.zip | |
(facemenu-color-name-equal): New function.
(list-colors-display): Use it to compare colors instead of
facemenu-color-equal.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/facemenu.el | 28 |
2 files changed, 33 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c0b9b0100dd..a6271544405 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2004-05-20 Michael Mauger <mmaug@yahoo.com> | ||
| 2 | |||
| 3 | * facemenu.el (facemenu-color-name-equal): New function. | ||
| 4 | (list-colors-display): Use it to compare colors instead of | ||
| 5 | facemenu-color-equal. | ||
| 6 | |||
| 1 | 2004-05-20 Dan Nicolaescu <dann@ics.uci.edu> | 7 | 2004-05-20 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 8 | ||
| 3 | * compare-w.el (compare-windows-face): Use min-colors instead of | 9 | * compare-w.el (compare-windows-face): Use min-colors instead of |
diff --git a/lisp/facemenu.el b/lisp/facemenu.el index 3893e320655..e9af58fc73d 100644 --- a/lisp/facemenu.el +++ b/lisp/facemenu.el | |||
| @@ -480,9 +480,19 @@ of colors that the current display can handle." | |||
| 480 | (when (and (null list) (> (display-color-cells) 0)) | 480 | (when (and (null list) (> (display-color-cells) 0)) |
| 481 | (setq list (defined-colors)) | 481 | (setq list (defined-colors)) |
| 482 | ;; Delete duplicate colors. | 482 | ;; Delete duplicate colors. |
| 483 | |||
| 484 | ;; Identify duplicate colors by the name rather than the color | ||
| 485 | ;; value. For example, on MS-Windows, logical colors are added to | ||
| 486 | ;; the list that might have the same value but have different | ||
| 487 | ;; names and meanings. For example, `SystemMenuText' (the color | ||
| 488 | ;; w32 uses for the text in menu entries) and `SystemWindowText' | ||
| 489 | ;; (the default color w32 uses for the text in windows and | ||
| 490 | ;; dialogs) may be the same display color and be adjacent in the | ||
| 491 | ;; list. Detecting duplicates by name insures that both of these | ||
| 492 | ;; colors remain despite identical color values. | ||
| 483 | (let ((l list)) | 493 | (let ((l list)) |
| 484 | (while (cdr l) | 494 | (while (cdr l) |
| 485 | (if (facemenu-color-equal (car l) (car (cdr l))) | 495 | (if (facemenu-color-name-equal (car l) (car (cdr l))) |
| 486 | (setcdr l (cdr (cdr l))) | 496 | (setcdr l (cdr (cdr l))) |
| 487 | (setq l (cdr l))))) | 497 | (setq l (cdr l))))) |
| 488 | (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color)) | 498 | (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color)) |
| @@ -515,6 +525,22 @@ determine the correct answer." | |||
| 515 | (cond ((equal a b) t) | 525 | (cond ((equal a b) t) |
| 516 | ((equal (color-values a) (color-values b))))) | 526 | ((equal (color-values a) (color-values b))))) |
| 517 | 527 | ||
| 528 | (defun facemenu-color-name-equal (a b) | ||
| 529 | "Return t if colors A and B are the same color. | ||
| 530 | A and B should be strings naming colors. These names are | ||
| 531 | downcased, stripped of spaces and the string `grey' is turned | ||
| 532 | into `gray'. This accommodates alternative spellings of colors | ||
| 533 | found commonly in the list. It returns nil if the colors differ." | ||
| 534 | (progn | ||
| 535 | (setq a (replace-regexp-in-string "grey" "gray" | ||
| 536 | (replace-regexp-in-string " " "" | ||
| 537 | (downcase a))) | ||
| 538 | b (replace-regexp-in-string "grey" "gray" | ||
| 539 | (replace-regexp-in-string " " "" | ||
| 540 | (downcase b)))) | ||
| 541 | |||
| 542 | (equal a b))) | ||
| 543 | |||
| 518 | (defun facemenu-add-face (face &optional start end) | 544 | (defun facemenu-add-face (face &optional start end) |
| 519 | "Add FACE to text between START and END. | 545 | "Add FACE to text between START and END. |
| 520 | If START is nil or START to END is empty, add FACE to next typed character | 546 | If START is nil or START to END is empty, add FACE to next typed character |