changeset 111682:2c6350617cc3

shr.el (shr-color->hexadecimal): Autoload. shr.el (shr-descend): Add color to all tags and remove the tag-font and tag-span functions.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 23 Nov 2010 08:21:09 +0000
parents 1a0c949aa8d5
children 01aefe45207c
files lisp/gnus/ChangeLog lisp/gnus/shr.el
diffstat 2 files changed, 28 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Tue Nov 23 09:00:56 2010 +0100
+++ b/lisp/gnus/ChangeLog	Tue Nov 23 08:21:09 2010 +0000
@@ -1,3 +1,8 @@
+2010-11-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-color->hexadecimal): Autoload.
+	(shr-descend): Add color to all tags.
+
 2010-11-22  Julien Danjou  <julien@danjou.info>
 
 	* shr.el (shr-tag-color-check): Convert colors to hexadecimal with
--- a/lisp/gnus/shr.el	Tue Nov 23 09:00:56 2010 +0100
+++ b/lisp/gnus/shr.el	Tue Nov 23 08:21:09 2010 +0000
@@ -191,10 +191,17 @@
     (nreverse result)))
 
 (defun shr-descend (dom)
-  (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray)))
+  (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray))
+	(style (cdr (assq :style (cdr dom))))
+	(start (point)))
+    (when (and style
+	       (string-match "color" style))
+      (setq style (shr-parse-style style)))
     (if (fboundp function)
 	(funcall function (cdr dom))
-      (shr-generic (cdr dom)))))
+      (shr-generic (cdr dom)))
+    (when (consp style)
+      (shr-insert-color-overlay (cdr (assq 'color style)) start (point)))))
 
 (defun shr-generic (cont)
   (dolist (sub cont)
@@ -485,6 +492,20 @@
   "Encode URL."
   (browse-url-url-encode-chars url "[)$ ]"))
 
+(autoload 'shr-color-visible "shr-color")
+(autoload 'shr-color->hexadecimal "shr-color")
+(defun shr-color-check (fg &optional bg)
+  "Check that FG is visible on BG."
+  (shr-color-visible (or (shr-color->hexadecimal bg)
+                         (frame-parameter nil 'background-color))
+                     (shr-color->hexadecimal fg) (not bg)))
+
+(defun shr-insert-color-overlay (color start end)
+  (when color
+    (let ((overlay (make-overlay start end)))
+      (overlay-put overlay 'face (cons 'foreground-color
+                                       (cadr (shr-color-check color)))))))
+
 ;;; Tag-specific rendering rules.
 
 (defun shr-tag-p (cont)
@@ -517,31 +538,6 @@
 (defun shr-tag-s (cont)
   (shr-fontize-cont cont 'strike-through))
 
-(autoload 'shr-color-visible "shr-color")
-(defun shr-tag-color-check (fg &optional bg)
-  "Check that FG is visible on BG."
-  (shr-color-visible (or (shr-color->hexadecimal bg)
-                         (frame-parameter nil 'background-color))
-                     (shr-color->hexadecimal fg) (not bg)))
-
-(defun shr-tag-insert-color-overlay (color start end)
-  (when color
-    (let ((overlay (make-overlay start end)))
-      (overlay-put overlay 'face (cons 'foreground-color
-                                       (cadr (shr-tag-color-check color)))))))
-
-(defun shr-tag-span (cont)
-  (let ((start (point))
-	(color (cdr (assq 'color (shr-parse-style (cdr (assq :style cont)))))))
-    (shr-generic cont)
-    (shr-tag-insert-color-overlay color start (point))))
-
-(defun shr-tag-font (cont)
-  (let ((start (point))
-        (color (cdr (assq :color cont))))
-    (shr-generic cont)
-    (shr-tag-insert-color-overlay color start (point))))
-
 (defun shr-parse-style (style)
   (when style
     (let ((plist nil))