From 19c0ca5c8830e654fb9c54cff122fb684e2358f4 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 7 Feb 2012 21:14:31 +0100 Subject: [PATCH] Only strip whitespace from too-wide lines in shr * shr.el (shr-remove-trailing-whitespace): Don't strip whitespace from lines that are narrower than the window width. Otherwise background "blocks" will look less readable. --- lisp/ChangeLog | 6 ++++++ lisp/shr.el | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dc8459333..217fde612 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-02-07 Lars Ingebrigtsen + + * shr.el (shr-remove-trailing-whitespace): Don't strip whitespace from + lines that are narrower than the window width. Otherwise background + "blocks" will look less readable. + 2012-02-07 Katsumi Yamaoka * gnus-sum.el (gnus-summary-show-thread): Revert last two changes. diff --git a/lisp/shr.el b/lisp/shr.el index deaef1d3f..7af8e31f7 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -153,16 +153,17 @@ DOM should be a parse tree as generated by (shr-remove-trailing-whitespace start (point)))) (defun shr-remove-trailing-whitespace (start end) - (save-restriction - (narrow-to-region start end) - (delete-trailing-whitespace) - (goto-char start) - (while (not (eobp)) - (end-of-line) - (dolist (overlay (overlays-at (point))) - (when (overlay-get overlay 'before-string) - (overlay-put overlay 'before-string nil))) - (forward-line 1)))) + (let ((width (window-width))) + (save-restriction + (narrow-to-region start end) + (goto-char start) + (while (not (eobp)) + (end-of-line) + (when (> (current-column) width) + (dolist (overlay (overlays-at (point))) + (when (overlay-get overlay 'before-string) + (overlay-put overlay 'before-string nil)))) + (forward-line 1))))) (defun shr-copy-url () "Copy the URL under point to the kill ring. -- 2.25.1