GNU bug report logs -
#2773
feature request: option for css mode to highlight #rrggbb text
Previous Next
Reported by: xah lee <xah <at> xahlee.org>
Date: Wed, 25 Mar 2009 00:45:04 UTC
Severity: wishlist
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
this is a feature request, for a option for css mode to highlight
#rrggbb text.
Explanation:
in CSS, there are lots of RGB values, e.g.
pre.c {border-color:#454545}
pre.java {border-color:#a020f0}
pre.haskell {border-color:#00b2ee}
pre.ocaml {border-color:#6b8e23}
it is very convenient if the rgb code can be colored by its value, so
that users can visually see what color they represent.
the css-mode that comes with emacs 22 doesn't seems to support this
feature. (doesn't seem to have customize-group support)
Here's a implementation that i've been using for a few months.
;; by Nikolaj Schumacher. http://www.emacswiki.org/emacs/HexColour
(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 ()
(interactive)
(font-lock-add-keywords nil hexcolor-keywords))
(add-hook 'css-mode-hook 'hexcolor-add-to-font-lock)
Note: CSS spec also allows this short form #RGB, where each of the
rgb is a single char. e.g. #f3c is the same as #ff33cc. The above
code need a bit tweak for this case.
In GNU Emacs 22.2.1 (powerpc-apple-darwin8.11.0, Carbon Version 1.6.0)
of 2008-04-05 on g5.tokyo.stp.isas.jaxa.jp
Thanks.
Xah
∑ http://xahlee.org/
☄
This bug report was last modified 13 years and 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.