From: Lars Magne Ingebrigtsen Date: Tue, 23 Nov 2010 08:21:09 +0000 (+0000) Subject: shr.el (shr-color->hexadecimal): Autoload. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~45^2~149 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ebe7955725a68a4c449fc287ab1232495da3b6e5;p=emacs.git shr.el (shr-color->hexadecimal): Autoload. shr.el (shr-descend): Add color to all tags and remove the tag-font and tag-span functions. --- diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index d791cf10aaf..2bfba62692a 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,8 @@ +2010-11-23 Lars Magne Ingebrigtsen + + * shr.el (shr-color->hexadecimal): Autoload. + (shr-descend): Add color to all tags. + 2010-11-22 Julien Danjou * shr.el (shr-tag-color-check): Convert colors to hexadecimal with diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 60fa1271939..21bfdd37723 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -191,10 +191,17 @@ redirects somewhere else." (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 @@ START, and END." "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 @@ START, and END." (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))