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: Chris McMahan
Subject: Re: Fontify: coloring rgb hex code by its value
Date: Sat, 26 Apr 2008 14:09:38 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (windows-nt)

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


reply via email to

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