GNU bug report logs -
#4033
23.1; list-colors-display is misleading
Previous Next
Full log
Message #80 received at 4033 <at> emacsbugs.donarmstrong.com (full text, mbox):
> > > 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))
rgb-width)
(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.
This bug report was last modified 15 years and 350 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.