all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fontify: coloring rgb hex code by its value
@ 2008-04-25  2:11 Xah
  2008-04-25 15:35 ` Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Xah @ 2008-04-25  2:11 UTC (permalink / raw)
  To: help-gnu-emacs

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.

Thanks.

  Xah
  xah@xahlee.org
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Fontify: coloring rgb hex code by its value
  2008-04-25  2:11 Fontify: coloring rgb hex code by its value Xah
@ 2008-04-25 15:35 ` Drew Adams
  2008-04-26 18:09 ` Chris McMahan
       [not found] ` <mailman.10811.1209137778.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2008-04-25 15:35 UTC (permalink / raw)
  To: 'Xah', help-gnu-emacs

> 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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fontify: coloring rgb hex code by its value
  2008-04-25  2:11 Fontify: coloring rgb hex code by its value Xah
  2008-04-25 15:35 ` Drew Adams
@ 2008-04-26 18:09 ` Chris McMahan
  2008-04-27  9:39   ` Nikolaj Schumacher
       [not found]   ` <mailman.10854.1209289187.18990.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.10811.1209137778.18990.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 6+ messages in thread
From: Chris McMahan @ 2008-04-26 18:09 UTC (permalink / raw)
  To: help-gnu-emacs

Here's what I have in my .emacs (I culled of the net somewhere a while back).

I'm sure you can adapt this to whatever mode you want.

- Chris

;;;======================================================================
;;; automatically color hex color strings
(defvar hexcolor-keywords
  '(("#[abcdef[:digit:]]\\{6\\}"
     (0 (put-text-property (match-beginning 0)
			   (match-end 0)
			   'face (list :background
				       (match-string-no-properties 0)))))))

(defun hexcolor-add-to-font-lock ()
  (font-lock-add-keywords nil hexcolor-keywords))
(add-hook 'emacs-lisp-mode-hook 'hexcolor-add-to-font-lock)
(add-hook 'nxml-mode-hook 'hexcolor-add-to-font-lock)


Xah <xahlee@gmail.com> writes:

> 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.
>
> Thanks.
>
>   Xah
>   xah@xahlee.org
> ∑ http://xahlee.org/
>
> ☄

-- 
     (.   .)
  =ooO=(_)=Ooo=====================================
  Chris McMahan | first_initiallastname@one.dot.net
  =================================================


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fontify: coloring rgb hex code by its value
  2008-04-26 18:09 ` Chris McMahan
@ 2008-04-27  9:39   ` Nikolaj Schumacher
       [not found]   ` <mailman.10854.1209289187.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Nikolaj Schumacher @ 2008-04-27  9:39 UTC (permalink / raw)
  To: Chris McMahan; +Cc: help-gnu-emacs

Chris McMahan <first_initiallastname@one.dot.net> wrote:

> Here's what I have in my .emacs (I culled of the net somewhere a while
> back).

probably from http://www.emacswiki.org/cgi-bin/emacs-en/HexColour

It contains a few enhanced versions, as well.


regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fontify: coloring rgb hex code by its value
       [not found]   ` <mailman.10854.1209289187.18990.help-gnu-emacs@gnu.org>
@ 2008-04-28 14:14     ` Chris McMahan
  0 siblings, 0 replies; 6+ messages in thread
From: Chris McMahan @ 2008-04-28 14:14 UTC (permalink / raw)
  To: help-gnu-emacs

Nikolaj Schumacher <n_schumacher@web.de> writes:

> Chris McMahan <first_initiallastname@one.dot.net> wrote:
>
>> Here's what I have in my .emacs (I culled of the net somewhere a while
>> back).
>
> probably from http://www.emacswiki.org/cgi-bin/emacs-en/HexColour
>
> It contains a few enhanced versions, as well.
>
> regards,
> Nikolaj Schumacher

That was the place indeed! Thanks for the update notice!

- Chris

-- 
     (.   .)
  =ooO=(_)=Ooo=====================================
  Chris McMahan | first_initiallastname@one.dot.net
  =================================================


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fontify: coloring rgb hex code by its value
       [not found] ` <mailman.10811.1209137778.18990.help-gnu-emacs@gnu.org>
@ 2008-05-03  5:52   ` Xah
  0 siblings, 0 replies; 6+ messages in thread
From: Xah @ 2008-05-03  5:52 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks all. Very helpful.

 Xah

On Apr 25, 8:35 am, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > i seems to recall that there's a module that will fontify ahexcolor
> > 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 &optionalhex-rgb)
>   (let ((rgb-string (orhex-rgb (hexrgb-color-name-to-hexcolor-name))))
>     (put-text-property 0 (length rgb-string) 'face
>                        (cons 'background-colorrgb-string)
>                        rgb-string)
>     (list (listcolor-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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-03  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-25  2:11 Fontify: coloring rgb hex code by its value Xah
2008-04-25 15:35 ` Drew Adams
2008-04-26 18:09 ` Chris McMahan
2008-04-27  9:39   ` Nikolaj Schumacher
     [not found]   ` <mailman.10854.1209289187.18990.help-gnu-emacs@gnu.org>
2008-04-28 14:14     ` Chris McMahan
     [not found] ` <mailman.10811.1209137778.18990.help-gnu-emacs@gnu.org>
2008-05-03  5:52   ` Xah

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.