[Top][All Lists]

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

bug#4033: 23.1; list-colors-display is misleading

From: Drew Adams
Subject: bug#4033: 23.1; list-colors-display is misleading
Date: Tue, 4 Aug 2009 19:58:10 -0700

> > > I have had at least one user state that he thought that, since the
> > > form shown is #RRGGBB, his colors had only that granularity.  IOW,
> > > even if one's system allows colors of the form #RRRRGGGGBBBB (more
> > > colors), the color names are translated to hex strings of the form
> > > #RRGGBB (fewer colors).
> > 
> > Could you show a formula that calculates the color granularity?
> > 
> > We could use it to print colors in the short format #RRGGBB
> > for the smaller color space and #RRRRGGGGBBBB otherwise.

This seems to DTRT, for printing with an RGB format that reflects the color
support of the display:

(defun list-colors-print (list)
  (let ((rgb-format  (facemenu-rgb-format-for-display))
        (col         (car list))
    (when (consp col) (setq col  (car col)))
    (setq rgb-width  (1+ (length (format rgb-format 1 1 1))))
    (dolist (color list)
      (if (consp color)
          (when (cdr color)
            (setq color (sort color (lambda (a b)
                                      (string< (downcase a) (downcase b))))))
        (setq color (list color)))
      (put-text-property (prog1 (point)
                           (insert (car color)) (indent-to 22))
                         (point) 'face (list ':background (car color)))
      (put-text-property (prog1 (point)
                           (insert " " (if (cdr color)
                                           (mapconcat 'identity (cdr color) ",
                                         (car color))))
                         (point) 'face (list ':foreground (car color)))
      (indent-to (max (- (window-width) rgb-width) 44))
      (insert (apply 'format rgb-format (mapcar (lambda (c) (lsh c -8))
                                                (color-values (car color)))))
      (insert "\n")))
  (goto-char (point-min)))

The question remains whether this is a useful/reasonable thing to do.

reply via email to

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