(shr-add-font): Don't put the font properties on the newline or the indentation.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 21 Oct 2010 01:44:28 +0000 (03:44 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 21 Oct 2010 01:44:28 +0000 (03:44 +0200)
lisp/ChangeLog
lisp/shr.el

index 5e42331..3fba14c 100644 (file)
@@ -1,5 +1,8 @@
 2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * shr.el (shr-add-font): Don't put the font properties on the newline
+       or the indentation.
+
        * message.el (message-fix-before-sending): Change options when sending
        non-printable characters.
 
        * message.el (message-fix-before-sending): Change options when sending
        non-printable characters.
 
index acf47aa..9645f04 100644 (file)
@@ -318,9 +318,20 @@ redirects somewhere else."
     (dolist (type types)
       (shr-add-font (or shr-start (point)) (point) type))))
 
     (dolist (type types)
       (shr-add-font (or shr-start (point)) (point) type))))
 
+;; Add an overlay in the region, but avoid putting the font properties
+;; on blank text at the start of the line, and the newline at the end,
+;; to avoid ugliness.
 (defun shr-add-font (start end type)
 (defun shr-add-font (start end type)
-  (let ((overlay (make-overlay start end)))
-    (overlay-put overlay 'face type)))
+  (save-excursion
+    (goto-char start)
+    (while (< (point) end)
+      (when (bolp)
+       (skip-chars-forward " "))
+      (let ((overlay (make-overlay (point) (min (line-end-position) end))))
+       (overlay-put overlay 'face type))
+      (if (< (line-end-position) end)
+         (forward-line 1)
+       (goto-char end)))))
 
 (defun shr-browse-url ()
   "Browse the URL under point."
 
 (defun shr-browse-url ()
   "Browse the URL under point."