summaryrefslogtreecommitdiff
path: root/lisp/facemenu.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-06-12 13:12:15 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-06-12 13:12:15 -0400
commit89877f5f3ca40387d5aa966c1d4df1cce49ccb81 (patch)
treeda3648d369c1cce647604df36590f7418d1b65b8 /lisp/facemenu.el
parent6e6e5760b3bafc41e425aad03ec61e59731713d5 (diff)
downloademacs-89877f5f3ca40387d5aa966c1d4df1cce49ccb81.tar.gz
Add all rgb.txt color names to x-colors.
* facemenu.el (list-colors-print): Don't print extra names if it will overflow the window width. * term/common-win.el (x-colors): Add all the color names defined in rgb.txt (Bug#6332).
Diffstat (limited to 'lisp/facemenu.el')
-rw-r--r--lisp/facemenu.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index b7c9f359095..187383d44e2 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -526,15 +526,27 @@ name."
(let* ((opoint (point))
(color-values (color-values (car color)))
(light-p (>= (apply 'max color-values)
- (* (car (color-values "white")) .5))))
+ (* (car (color-values "white")) .5)))
+ (max-len (max (- (window-width) 33) 20)))
(insert (car color))
(indent-to 22)
(put-text-property opoint (point) 'face `(:background ,(car color)))
(put-text-property
(prog1 (point)
- (insert " " (if (cdr color)
- (mapconcat 'identity (cdr color) ", ")
- (car color))))
+ (insert " ")
+ (if (cdr color)
+ ;; Insert as many color names as possible, fitting max-len.
+ (let ((names (list (car color)))
+ (others (cdr color))
+ (len (length (car color)))
+ newlen)
+ (while (and others
+ (< (setq newlen (+ len 2 (length (car others))))
+ max-len))
+ (setq len newlen)
+ (push (pop others) names))
+ (insert (mapconcat 'identity (nreverse names) ", ")))
+ (insert (car color))))
(point)
'face (list :foreground (car color)))
(indent-to (max (- (window-width) 8) 44))