From b40950bfce6aeaf2fb6e66c9d3859f4e321fa074 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Fri, 26 Nov 2010 07:35:42 +0000 Subject: [PATCH] shr.el (shr-insert): Revert last change. shr.el (shr-find-fill-point): Never leave point being at bol; relax the kinsoku limitation when rendering tables. --- lisp/gnus/ChangeLog | 6 +++++ lisp/gnus/shr.el | 75 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 2a4b97bd8d2..01e9d74a581 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,9 @@ +2010-11-26 Katsumi Yamaoka + + * shr.el (shr-insert): Revert last change. + (shr-find-fill-point): Never leave point being at bol; + relax the kinsoku limitation when rendering tables. + 2010-11-26 Lars Magne Ingebrigtsen * nnmail.el (nnmail-expiry-target-group): Protect against degenerate diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 1746c9aee4b..69973fbfb50 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -254,7 +254,7 @@ redirects somewhere else." (while (and (> (current-column) shr-width) (progn (setq found (shr-find-fill-point)) - (not (or (bolp) (eolp))))) + (not (eolp)))) (when (eq (preceding-char) ? ) (delete-char -1)) (insert "\n") @@ -278,7 +278,8 @@ redirects somewhere else." (or (setq failed (= (current-column) shr-indentation)) (eq (preceding-char) ? ) (eq (following-char) ? ) - (aref fill-find-break-point-function-table (preceding-char)))) + (aref fill-find-break-point-function-table (preceding-char)) + (aref (char-category-set (preceding-char)) ?>))) (backward-char 1)) (if failed ;; There's no breakable point, so we give it up. @@ -287,30 +288,52 @@ redirects somewhere else." (while (aref fill-find-break-point-function-table (preceding-char)) (backward-char 1)) nil) - (or (eolp) - ;; Don't put kinsoku-bol characters at the beginning of a line, - ;; or kinsoku-eol characters at the end of a line, - (let ((count 4)) - (if (or shr-kinsoku-shorten - (and (aref (char-category-set (preceding-char)) ?<) - (progn - (setq count (1- count)) - (backward-char 1) - t))) - (while (and - (>= (setq count (1- count)) 0) - (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) - (or (aref (char-category-set (preceding-char)) ?<) - (aref (char-category-set (following-char)) ?>))) - (backward-char 1)) - (while (and (>= (setq count (1- count)) 0) - (aref (char-category-set (following-char)) ?>) - (aref fill-find-break-point-function-table - (following-char))) - (forward-char 1))) - (when (eq (following-char) ? ) - (forward-char 1)) - t))))) + (or + (eolp) + (progn + ;; Don't put kinsoku-bol characters at the beginning of a line, + ;; or kinsoku-eol characters at the end of a line. + (cond + (shr-kinsoku-shorten + (while (and + (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) + (not (or (aref (char-category-set (preceding-char)) ?>) + (aref (char-category-set (following-char)) ?<))) + (or (aref (char-category-set (preceding-char)) ?<) + (aref (char-category-set (following-char)) ?>))) + (backward-char 1))) + ((aref (char-category-set (preceding-char)) ?<) + (let ((count 3)) + (while (progn + (backward-char 1) + (and + (> (setq count (1- count)) 0) + (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) + (or (aref (char-category-set (preceding-char)) ?<) + (aref (char-category-set (following-char)) ?>)))))) + (if (and (setq failed (= (current-column) shr-indentation)) + (re-search-forward "\\c|" (line-end-position) 'move)) + ;; There's no breakable point that doesn't violate kinsoku, + ;; so we look for the second best position. + (let (bp) + (while (and (<= (current-column) shr-width) + (progn + (setq bp (point)) + (not (eolp))) + (aref fill-find-break-point-function-table + (following-char))) + (forward-char 1)) + (goto-char (or bp (line-end-position)))))) + (t + (let ((count 4)) + (while (and (>= (setq count (1- count)) 0) + (aref (char-category-set (following-char)) ?>) + (aref fill-find-break-point-function-table + (following-char))) + (forward-char 1))))) + (when (eq (following-char) ? ) + (forward-char 1)) + (not failed)))))) (defun shr-ensure-newline () (unless (zerop (current-column)) -- 2.11.4.GIT