[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master a5f2403: Avoid an infloop in shr filling when not u
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master a5f2403: Avoid an infloop in shr filling when not using fonts |
Date: |
Sun, 15 Apr 2018 09:19:00 -0400 (EDT) |
branch: master
commit a5f2403cc2d1fb81fa64d2e3650d3a59d47a5637
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Avoid an infloop in shr filling when not using fonts
* lisp/net/shr.el (shr-fill-line): If we have an indentation
that's wider than the width of what we're trying to fill, just
give up. This avoids an infloop when `shr-use-fonts' in nil.
---
lisp/net/shr.el | 75 ++++++++++++++++++++++++++++++---------------------------
1 file changed, 39 insertions(+), 36 deletions(-)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 5eb35b7..655f142 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -719,44 +719,47 @@ size, and full-buffer size."
`,(shr-face-background face))))
(setq start (point))
(setq shr-indentation (or continuation shr-indentation))
- (shr-vertical-motion shr-internal-width)
- (when (looking-at " $")
- (delete-region (point) (line-end-position)))
- (while (not (eolp))
- ;; We have to do some folding. First find the first
- ;; previous point suitable for folding.
- (if (or (not (shr-find-fill-point (line-beginning-position)))
- (= (point) start))
- ;; We had unbreakable text (for this width), so just go to
- ;; the first space and carry on.
- (progn
- (beginning-of-line)
- (skip-chars-forward " ")
- (search-forward " " (line-end-position) 'move)))
- ;; Success; continue.
- (when (= (preceding-char) ?\s)
- (delete-char -1))
- (let ((gap-start (point)))
- (insert "\n")
- (shr-indent)
- (when (and (> (1- gap-start) (point-min))
- ;; The link on both sides of the newline are the
- ;; same...
- (equal (get-text-property (point) 'shr-url)
- (get-text-property (1- gap-start) 'shr-url)))
- ;; ... so we join the two bits into one link logically, but
- ;; not visually. This makes navigation between links work
- ;; well, but avoids underscores before the link on the next
- ;; line when indented.
- (let ((props (copy-sequence (text-properties-at (point)))))
- ;; We don't want to use the faces on the indentation, because
- ;; that's ugly.
- (setq props (plist-put props 'face nil))
- (add-text-properties gap-start (point) props))))
- (setq start (point))
+ ;; If we have an indentation that's wider than the width we're
+ ;; trying to fill to, then just give up and don't do any filling.
+ (when (< shr-indentation shr-internal-width)
(shr-vertical-motion shr-internal-width)
(when (looking-at " $")
- (delete-region (point) (line-end-position))))))
+ (delete-region (point) (line-end-position)))
+ (while (not (eolp))
+ ;; We have to do some folding. First find the first
+ ;; previous point suitable for folding.
+ (if (or (not (shr-find-fill-point (line-beginning-position)))
+ (= (point) start))
+ ;; We had unbreakable text (for this width), so just go to
+ ;; the first space and carry on.
+ (progn
+ (beginning-of-line)
+ (skip-chars-forward " ")
+ (search-forward " " (line-end-position) 'move)))
+ ;; Success; continue.
+ (when (= (preceding-char) ?\s)
+ (delete-char -1))
+ (let ((gap-start (point)))
+ (insert "\n")
+ (shr-indent)
+ (when (and (> (1- gap-start) (point-min))
+ ;; The link on both sides of the newline are the
+ ;; same...
+ (equal (get-text-property (point) 'shr-url)
+ (get-text-property (1- gap-start) 'shr-url)))
+ ;; ... so we join the two bits into one link logically, but
+ ;; not visually. This makes navigation between links work
+ ;; well, but avoids underscores before the link on the next
+ ;; line when indented.
+ (let ((props (copy-sequence (text-properties-at (point)))))
+ ;; We don't want to use the faces on the indentation, because
+ ;; that's ugly.
+ (setq props (plist-put props 'face nil))
+ (add-text-properties gap-start (point) props))))
+ (setq start (point))
+ (shr-vertical-motion shr-internal-width)
+ (when (looking-at " $")
+ (delete-region (point) (line-end-position)))))))
(defun shr-find-fill-point (start)
(let ((bp (point))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master a5f2403: Avoid an infloop in shr filling when not using fonts,
Lars Ingebrigtsen <=