From: Lars Ingebrigtsen Date: Wed, 25 Dec 2013 22:52:15 +0000 (+0100) Subject: Don't infloop when we can't find a good place to break lines in shr X-Git-Url: https://git.hcoop.net/bpt/emacs.git/commitdiff_plain/f7f071dcf47fc47b987d9a9700bf558844262d19 Don't infloop when we can't find a good place to break lines in shr (shr-insert): Don't infloop if we can't find a good place to break the line. Fixes: debbugs:16256 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 18f0a9f22f..76e175919e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -12,6 +12,8 @@ 2013-12-25 Lars Ingebrigtsen * net/shr.el (shr-visit-file): Remove debugging function. + (shr-insert): Don't infloop if we can't find a good place to break + the line (bug#16256). 2013-12-25 Fabián Ezequiel Gallina diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 5b8ab28c83..93e2be0086 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -455,11 +455,10 @@ size, and full-buffer size." (insert elem) (setq shr-state nil) (let (found) - (while (and (> (current-column) shr-width) - (> shr-width 0) - (progn - (setq found (shr-find-fill-point)) - (not (eolp)))) + (when (and (> (current-column) shr-width) + (progn + (setq found (shr-find-fill-point)) + (not (eolp)))) (when (eq (preceding-char) ? ) (delete-char -1)) (insert "\n") @@ -528,12 +527,12 @@ size, and full-buffer size." (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) (or (shr-char-kinsoku-eol-p (preceding-char)) (shr-char-kinsoku-bol-p (following-char))))))) - (if (setq failed (= (current-column) shr-indentation)) - ;; There's no breakable point that doesn't violate kinsoku, - ;; so we go to the second best position. - (if (looking-at "\\(\\c<+\\)\\c<") - (goto-char (match-end 1)) - (forward-char 1)))) + (when (setq failed (= (current-column) shr-indentation)) + ;; There's no breakable point that doesn't violate kinsoku, + ;; so we go to the second best position. + (if (looking-at "\\(\\c<+\\)\\c<") + (goto-char (match-end 1)) + (forward-char 1)))) ((shr-char-kinsoku-bol-p (following-char)) ;; Find forward the point where kinsoku-bol characters end. (let ((count 4))