emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA-diffs] /srv/bzr/emacs/elpa r297: rainbow-mode 0.3


From: Julien Danjou
Subject: [ELPA-diffs] /srv/bzr/emacs/elpa r297: rainbow-mode 0.3
Date: Fri, 09 Nov 2012 12:36:23 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 297
committer: Julien Danjou <address@hidden>
branch nick: elpa
timestamp: Fri 2012-11-09 12:36:23 +0100
message:
  rainbow-mode 0.3
  
  * rainbow-mode.el: avoid colorizing HTML entities
modified:
  packages/rainbow-mode/rainbow-mode.el
=== modified file 'packages/rainbow-mode/rainbow-mode.el'
--- a/packages/rainbow-mode/rainbow-mode.el     2011-09-23 17:00:24 +0000
+++ b/packages/rainbow-mode/rainbow-mode.el     2012-11-09 11:36:23 +0000
@@ -1,10 +1,10 @@
 ;;; rainbow-mode.el --- Colorize color names in buffers
 
-;; Copyright (C) 2010-2011 Free Software Foundation, Inc
+;; Copyright (C) 2010-2012 Free Software Foundation, Inc
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: faces
-;; Version: 0.2
+;; Version: 0.3
 
 ;; This file is part of GNU Emacs.
 
@@ -42,14 +42,16 @@
 
 ;; Hexadecimal colors
 (defvar rainbow-hexadecimal-colors-font-lock-keywords
-  '(("#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}"
+  '(("[^&]\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
+     (1 (rainbow-colorize-itself 1)))
+    ("^\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
      (0 (rainbow-colorize-itself)))
     
("[Rr][Gg][Bb]:[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}"
      (0 (rainbow-colorize-itself)))
     ("[Rr][Gg][Bb][Ii]:[0-9.]+/[0-9.]+/[0-9.]+"
      (0 (rainbow-colorize-itself)))
-    
("\\(?:[Cc][Ii][Ee]\\(?:[Xx][Yy][Zz]\\|[Uu][Vv][Yy]\\|[Xx][Yy][Yy]\\|[Ll][Aa][Bb]\\|[Ll][Uu][Vv]\\)\\|[Tt][Ee][Kk][Hh][Vv][Cc]\\):[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?"
-     (0 (rainbow-colorize-itself))))
+    
("\\(?:[Cc][Ii][Ee]\\(?:[Xx][Yy][Zz]\\|[Uu][Vv][Yy]\\|[Xx][Yy][Yy]\\|[Ll][Aa][Bb]\\|[Ll][Uu][Vv]\\)\\|[Tt][Ee][Kk][Hh][Vv][Cc]\\):[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?")
+    (0 (rainbow-colorize-itself)))
   "Font-lock keywords to add for hexadecimal colors.")
 
 ;; rgb() colors
@@ -280,19 +282,20 @@
   :group 'rainbow)
 
 ;; Functions
-(defun rainbow-colorize-match (color)
+(defun rainbow-colorize-match (color &optional match)
   "Return a matched string propertized with a face whose
 background is COLOR. The foreground is computed using
 `rainbow-color-luminance', and is either white or black."
-  (put-text-property
-   (match-beginning 0) (match-end 0)
-   'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
-                             "white" "black"))
-           (:background ,color))))
+  (let ((match (or match 0)))
+    (put-text-property
+     (match-beginning match) (match-end match)
+     'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
+                               "white" "black"))
+             (:background ,color)))))
 
-(defun rainbow-colorize-itself ()
+(defun rainbow-colorize-itself (&optional match)
   "Colorize a match with itself."
-  (rainbow-colorize-match (match-string-no-properties 0)))
+  (rainbow-colorize-match (match-string-no-properties (or match 0)) match))
 
 (defun rainbow-colorize-hexadecimal-without-sharp ()
   "Colorize an hexadecimal colors and prepend # to it."


reply via email to

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