diff options
| author | Lars Magne Ingebrigtsen | 2016-03-20 14:47:22 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2016-03-20 14:47:30 +0100 |
| commit | 61b2e837d8eefcba7ae8dbe442a818f05d5ed6f0 (patch) | |
| tree | f1c9334b24f9055314fd6a9ceb7a6ba9b03788a1 | |
| parent | 9dcf5998935c8aaa846d7585b81f0dcfe1935b3d (diff) | |
| download | emacs-61b2e837d8eefcba7ae8dbe442a818f05d5ed6f0.tar.gz emacs-61b2e837d8eefcba7ae8dbe442a818f05d5ed6f0.zip | |
Don't remove too much white space at the end of documents
* lisp/net/shr.el (shr--remove-blank-lines-at-the-end): Don't
remove too much white space -- leave it on the last line (in
case there's a background color).
| -rw-r--r-- | lisp/net/shr.el | 7 | ||||
| -rw-r--r-- | test/data/shr/ul-empty.txt | 2 |
2 files changed, 3 insertions, 6 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index cd55f223cf6..4adb4a6099c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -281,15 +281,12 @@ DOM should be a parse tree as generated by | |||
| 281 | (defun shr--remove-blank-lines-at-the-end (start end) | 281 | (defun shr--remove-blank-lines-at-the-end (start end) |
| 282 | (save-restriction | 282 | (save-restriction |
| 283 | (save-excursion | 283 | (save-excursion |
| 284 | (current-buffer) | ||
| 285 | (narrow-to-region start end) | 284 | (narrow-to-region start end) |
| 286 | (goto-char end) | 285 | (goto-char end) |
| 287 | (when (and (re-search-backward "[^ \n]" nil t) | 286 | (when (and (re-search-backward "[^ \n]" nil t) |
| 288 | (not (eobp))) | 287 | (not (eobp))) |
| 289 | (forward-char 1) | 288 | (forward-line 1) |
| 290 | (delete-region (point) (point-max)) | 289 | (delete-region (point) (point-max)))))) |
| 291 | (unless (bolp) | ||
| 292 | (insert "\n")))))) | ||
| 293 | 290 | ||
| 294 | (defun shr-copy-url (&optional image-url) | 291 | (defun shr-copy-url (&optional image-url) |
| 295 | "Copy the URL under point to the kill ring. | 292 | "Copy the URL under point to the kill ring. |
diff --git a/test/data/shr/ul-empty.txt b/test/data/shr/ul-empty.txt index acb41c47eb4..8993555425b 100644 --- a/test/data/shr/ul-empty.txt +++ b/test/data/shr/ul-empty.txt | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | * | 1 | * |
| 2 | 2 | ||
| 3 | Lala | 3 | Lala \ No newline at end of file |