From e6929b0b8a3c4a10023f700c6121f9e0b182aa8a Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Wed, 11 Feb 2015 15:34:07 +1100 Subject: [PATCH] (shr-fill-line): Preserve background colours when indenting/folding. --- lisp/ChangeLog | 1 + lisp/net/shr.el | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7274c9da8f2..7ec017c94ec 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,7 @@ * net/shr.el (shr-insert): Make sure the space inserted has the right font (for width). + (shr-fill-line): Preserve background colours when indenting/folding. 2015-02-10 Lars Ingebrigtsen diff --git a/lisp/net/shr.el b/lisp/net/shr.el index a4320853fd1..7a93c3a043c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -550,7 +550,12 @@ size, and full-buffer size." (point) 'shr-continuation-indentation)) start) (put-text-property (point) (1+ (point)) 'shr-indentation nil) - (shr-indent) + (let ((face (get-text-property (point) 'face)) + (background-start (point))) + (shr-indent) + (when face + (put-text-property background-start (point) 'face + `,(shr-face-background face)))) (setq start (point)) (setq shr-indentation (or continuation shr-indentation)) (shr-vertical-motion shr-internal-width) @@ -570,8 +575,13 @@ size, and full-buffer size." ;; Success; continue. (when (= (preceding-char) ?\s) (delete-char -1)) - (insert "\n") - (shr-indent) + (let ((face (get-text-property (point) 'face)) + (background-start (point))) + (insert "\n") + (shr-indent) + (when face + (put-text-property background-start (point) 'face + `,(shr-face-background face)))) (setq start (point)) (shr-vertical-motion shr-internal-width) (when (looking-at " $") -- 2.39.2