From ac5758d16288422dc7c91f152db612deb44ff3a7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 27 Dec 2013 03:21:42 +0100 Subject: [PATCH] shr didn't fill Japanese text correctly any more * net/shr.el (shr-find-fill-point): Don't try to fill if the indentation level is larger than the width, because that will infloop. (shr-insert): Fill repeatedly long texts, so that Japanese is formatted correctly. Fixes: debbugs:16263 --- lisp/ChangeLog | 8 ++++++++ lisp/net/shr.el | 17 +++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2831988efd..c764f97338 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2013-12-27 Lars Ingebrigtsen + + * net/shr.el (shr-find-fill-point): Don't try to fill if the + indentation level is larger than the width, because that will + infloop. + (shr-insert): Fill repeatedly long texts, so that Japanese is + formatted correctly (bug#16263). + 2013-12-26 João Távora * electric.el (electric-pair-mode): More flexible engine for skip- diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 93e2be0086..a4cfdfeb0c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -455,10 +455,10 @@ size, and full-buffer size." (insert elem) (setq shr-state nil) (let (found) - (when (and (> (current-column) shr-width) - (progn - (setq found (shr-find-fill-point)) - (not (eolp)))) + (while (and (> (current-column) shr-width) + (progn + (setq found (shr-find-fill-point)) + (not (eolp)))) (when (eq (preceding-char) ? ) (delete-char -1)) (insert "\n") @@ -478,7 +478,7 @@ size, and full-buffer size." (backward-char 1)) (let ((bp (point)) failed) - (while (not (or (setq failed (= (current-column) shr-indentation)) + (while (not (or (setq failed (< (current-column) shr-indentation)) (eq (preceding-char) ? ) (eq (following-char) ? ) (shr-char-breakable-p (preceding-char)) @@ -496,7 +496,8 @@ size, and full-buffer size." (while (setq found (re-search-forward "\\(\\c>\\)\\| \\|\\c<\\|\\c|" (line-end-position) 'move))) - (if (and found (not (match-beginning 1))) + (if (and found + (not (match-beginning 1))) (goto-char (match-beginning 0))))) (or (eolp) @@ -507,7 +508,7 @@ size, and full-buffer size." (while (and (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) (shr-char-kinsoku-eol-p (preceding-char))) (backward-char 1)) - (when (setq failed (= (current-column) shr-indentation)) + (when (setq failed (< (current-column) shr-indentation)) ;; There's no breakable point that doesn't violate kinsoku, ;; so we look for the second best position. (while (and (progn @@ -527,7 +528,7 @@ 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))))))) - (when (setq failed (= (current-column) shr-indentation)) + (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<") -- 2.20.1