all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chris McMahan <first_initiallastname@one.dot.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Fontify: coloring rgb hex code by its value
Date: Sat, 26 Apr 2008 14:09:38 -0400	[thread overview]
Message-ID: <u8wz0cwt9.fsf@one.dot.net> (raw)
In-Reply-To: 06adf465-6005-4b23-8d0e-1ba9411c7089@m1g2000pre.googlegroups.com

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
  =================================================


  parent reply	other threads:[~2008-04-26 18:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u8wz0cwt9.fsf@one.dot.net \
    --to=first_initiallastname@one.dot.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.