Start thinking about breaking CJVK text.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 11 Oct 2010 18:19:28 +0000 (20:19 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 11 Oct 2010 18:19:28 +0000 (20:19 +0200)
lisp/ChangeLog
lisp/shr.el

index 3f8b71c..8aeff44 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * shr.el (shr-current-column): New function.
+       (shr-find-fill-point): New function.
+
 2010-10-11  Michael Welsh Duggan  <md5i@md5i.com>  (tiny change)
 
        * sieve-manage.el (sieve-manage-open): Allow port names as well as port
index 2ad49dd..3311fa3 100644 (file)
@@ -217,7 +217,7 @@ redirects somewhere else."
        (unless shr-start
          (setq shr-start (point)))
        (insert elem)
-       (when (> (current-column) shr-width)
+       (when (> (shr-current-column) shr-width)
          (if (not (search-backward " " (line-beginning-position) t))
              (insert "\n")
            (delete-char 1)
@@ -230,6 +230,26 @@ redirects somewhere else."
       (unless (string-match "[ \t\n]\\'" text)
        (delete-char -1))))))
 
+(defun shr-find-fill-point ()
+  (let ((found nil))
+    (while (and (not found)
+               (not (bolp)))
+      (when (or (eq (preceding-char) ? )
+               (aref fill-find-break-point-function-table (preceding-char)))
+       (setq found (point)))
+      (backward-char 1))
+    (or found
+       (end-of-line))))
+
+(defun shr-current-column ()
+  (let ((column 0))
+    (save-excursion
+      (beginning-of-line)
+      (while (not (eolp))
+       (incf column (char-width (following-char)))
+       (forward-char 1)))
+    column))
+
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))
     (insert "\n")))