emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101968: shr.el (shr-insert): Remove


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101968: shr.el (shr-insert): Remove space inserted before or after a breakable character or at the beginning or the end of a line.
Date: Fri, 15 Oct 2010 08:10:56 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101968
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Fri 2010-10-15 08:10:56 +0000
message:
  shr.el (shr-insert): Remove space inserted before or after a breakable 
character or at the beginning or the end of a line.
  shr.el (shr-find-fill-point): Do kinsoku; find the second best point or give 
it up if there's no breakable point.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/shr.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-10-14 22:39:54 +0000
+++ b/lisp/gnus/ChangeLog       2010-10-15 08:10:56 +0000
@@ -1,3 +1,11 @@
+2010-10-15  Katsumi Yamaoka  <address@hidden>
+
+       * shr.el (shr-generic): Remove trailing space.
+       (shr-insert): Remove space inserted before or after a breakable
+       character or at the beginning or the end of a line.
+       (shr-find-fill-point): Do kinsoku; find the second best point or give
+       it up if there's no breakable point.
+
 2010-10-14  Lars Magne Ingebrigtsen  <address@hidden>
 
        * nnimap.el (nnimap-open-connection): Message when opening connection

=== modified file 'lisp/gnus/shr.el'
--- a/lisp/gnus/shr.el  2010-10-14 22:39:54 +0000
+++ b/lisp/gnus/shr.el  2010-10-15 08:10:56 +0000
@@ -218,20 +218,35 @@
        ;; starts.
        (unless shr-start
          (setq shr-start (point)))
+       ;; No space is needed before or after a breakable character or
+       ;; at the beginning of a line.
+       (when (and (eq (preceding-char) ? )
+                  (or (= (line-beginning-position) (1- (point)))
+                      (aref fill-find-break-point-function-table
+                            (char-after (- (point) 2)))
+                      (aref fill-find-break-point-function-table
+                            (aref elem 0))))
+         (delete-char -1))
        (insert elem)
        (while (> (current-column) shr-width)
-         (if (not (shr-find-fill-point))
-             (insert "\n")
-           (delete-char 1)
-           (insert "\n")
+         (unless (prog1
+                     (shr-find-fill-point)
+                   (when (eq (preceding-char) ? )
+                     (delete-char -1))
+                   (insert "\n"))
            (put-text-property (1- (point)) (point) 'shr-break t)
-           (when (> shr-indentation 0)
-             (shr-indent))
-           (end-of-line)))
+           ;; No space is needed at the beginning of a line.
+           (if (eq (following-char) ? )
+               (delete-char 1)))
+         (when (> shr-indentation 0)
+           (shr-indent))
+         (end-of-line))
        (insert " "))
       (unless (string-match "[ \t\n]\\'" text)
        (delete-char -1))))))
 
+(eval-and-compile (autoload 'kinsoku-longer "kinsoku"))
+
 (defun shr-find-fill-point ()
   (let ((found nil))
     (while (and (not found)
@@ -240,10 +255,26 @@
                     (aref fill-find-break-point-function-table
                           (preceding-char)))
                 (<= (current-column) shr-width))
-       (setq found (point)))
-      (backward-char 1))
-    (or found
-       (end-of-line))))
+       (setq found t))
+      (backward-char 1)
+      (when (bolp)
+       ;; There's no breakable point, so we give it up.
+       (end-of-line)
+       (while (aref fill-find-break-point-function-table
+                    (preceding-char))
+         (backward-char 1))
+       (setq found 'failed)))
+    (cond ((eq found t)
+          ;; Don't put kinsoku-bol characters at the beginning of a line.
+          (or (eobp)
+              (kinsoku-longer)
+              (not (aref fill-find-break-point-function-table
+                         (following-char)))
+              (forward-char 1)))
+         (found t)
+         (t
+          (end-of-line)
+          nil))))
 
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]