3

From EmacsWiki: Hex Colour, it is explained how to get in-line syntax highlighting of hex code, and other formats of color. For instance with

(defvar hexcolour-keywords
  '(("#[abcdef[:digit:]]\\{6\\}"
      (0 (put-text-property (match-beginning 0)
                            (match-end 0)
                            'face (list :background 
                                        (match-string-no-properties 0)))))))

But when I try this with some emacs-lisp such as

(set-face-attribute 'org-todo nil
                    :weight 'bold :box '(:line-width 1 :color "#D8ABA7")
                    :foreground "#D8ABA7" :background "#FFE6E4")

the hex is not given the color face. If I try M-x describe-face on these, I find face is org-block-background. Is there a good way to override this?

1 Answers1

6

You can also achieve this using rainbow-mode, which is part of ELPA. Install it with M-x package-install rainbow-mode and activate it with M-x rainbow-mode. It seems that the color changes don't occur until you edit the buffer.

erikstokes
  • 12,927
  • 2
  • 36
  • 56
  • "There is a good chance that someone already solved the problem, and made a package out of it". And an extra plus, package automagically inverts foreground to black or white for readability. – Brady Trainor Nov 02 '14 at 17:58