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

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

RE: Fontify: coloring rgb hex code by its value


From: Drew Adams
Subject: RE: Fontify: coloring rgb hex code by its value
Date: Fri, 25 Apr 2008 08:35:51 -0700

> i seems to recall that there's a module that will fontify a hex color
> code by its value.
> That is, if i have this line in my .css file:
> pre.php {border-color:#2e8b57}
> then the "#2e8b57" is colored using that value.
> anyone know what's the name of this module or where can i get it?
> A short code showing can this can be written will also be appreciated.

I believe this is done in the code for `list-colors-display'. That could be one
place to start. I do the same thing in some of my code, for example this:

(defun icicle-make-color-candidate (color-name &optional hex-rgb)
  (let ((rgb-string (or hex-rgb (hexrgb-color-name-to-hex color-name))))
    (put-text-property 0 (length rgb-string) 'face
                       (cons 'background-color rgb-string)
                       rgb-string)
    (list (list color-name rgb-string))))

That is in icicles-cmd.el:
http://www.emacswiki.org/cgi-bin/wiki/icicles-cmd.el

It uses code in hexrgb.el:
http://www.emacswiki.org/cgi-bin/wiki/hexrgb.el

See also command `palette' of palette.el, for similar code:
http://www.emacswiki.org/cgi-bin/wiki/palette.el





reply via email to

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