GNU bug report logs - #2773
feature request: option for css mode to highlight #rrggbb text

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2773 in the body.
You can then email your comments to 2773 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2773; Package emacs. (Wed, 25 Mar 2009 00:45:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to xah lee <xah <at> xahlee.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 25 Mar 2009 00:45:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: xah lee <xah <at> xahlee.org>
To: bug-gnu-emacs <at> gnu.org
Subject: feature request: option for css mode to highlight #rrggbb text
Date: Tue, 24 Mar 2009 17:35:19 -0700
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/

Severity set to `wishlist' from `normal' Request was from Juanma Barranquero <lekktu <at> gmail.com> to control <at> emacsbugs.donarmstrong.com. (Wed, 25 Mar 2009 10:15:03 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2773; Package emacs. (Fri, 22 Jul 2011 15:31:02 GMT) Full text and rfc822 format available.

Message #10 received at 2773 <at> debbugs.gnu.org (full text, mbox):

From: Julien Danjou <julien <at> danjou.info>
To: xah lee <xah <at> xahlee.org>
Cc: 2773 <at> debbugs.gnu.org
Subject: Re: feature request: option for css mode to highlight #rrggbb text
Date: Fri, 22 Jul 2011 17:30:48 +0200
[Message part 1 (text/plain, inline)]
On Wed, Mar 25 2009, xah lee wrote:

rainbow-mode is included into ELPA and does exactly that for css-mode,
but also for X colors or LaTeX.

Its inclusion has been discussed and refused into Emacs, therefore, I
think this bug should be closed.

-- 
Julien Danjou
❱ http://julien.danjou.info
[Message part 2 (application/pgp-signature, inline)]

bug closed, send any further explanations to 2773 <at> debbugs.gnu.org and xah lee <xah <at> xahlee.org> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 29 Oct 2011 06:21:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 26 Nov 2011 12:24:03 GMT) Full text and rfc822 format available.

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.