bug-gnu-emacs
[Top][All Lists]
Advanced

[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:36:06 -0700

> What about something like this:
> 
> (defun rgb-color-format-for-display ()
>   (let ((ncolors  (display-color-cells (selected-frame)))
>         (exp      0))
>     (while (> (lsh ncolors (- exp)) 1) (setq exp  (1+ exp)))
>     (setq exp  (/ exp 12))
>     (format "#%%0%dx%%0%dx%%0%dx" exp exp exp)))
> 
> For 16777216 colors, that gives #%02x%02x%02x, which seems right.
> 
> In `list-colors-print', we would then do this:
> 
> (insert (apply 'format (rgb-color-format-for-display)
>                (mapcar (lambda (c) (lsh c -8))
>                          (color-values (car color)))))
> 
> IOW, replace the hard-coded "#%02x%02x%02x" with 
> (rgb-color-format-for-display).

We would also want to first do that for one of the colors, to get the field
width, then use that here:

(indent-to (max (- (window-width) RGB-WIDTH) 44))

instead of hard-coding a width of 8, as now:

(indent-to (max (- (window-width) 8) 44))






reply via email to

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