aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2010-10-15 08:10:56 +0000
committerKatsumi Yamaoka2010-10-15 08:10:56 +0000
commit204380176cb3edf83951e3c8442bf959f077ea2a (patch)
tree11b3d701299b81417dd9fbc88a3768fc980f8ad1
parentcc98b2563e0497e7e4530d6f7dab75131bff64ac (diff)
downloademacs-204380176cb3edf83951e3c8442bf959f077ea2a.tar.gz
emacs-204380176cb3edf83951e3c8442bf959f077ea2a.zip
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.
-rw-r--r--lisp/gnus/ChangeLog8
-rw-r--r--lisp/gnus/shr.el53
2 files changed, 50 insertions, 11 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 27363445e35..4c722b3d8aa 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
12010-10-15 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * shr.el (shr-generic): Remove trailing space.
4 (shr-insert): Remove space inserted before or after a breakable
5 character or at the beginning or the end of a line.
6 (shr-find-fill-point): Do kinsoku; find the second best point or give
7 it up if there's no breakable point.
8
12010-10-14 Lars Magne Ingebrigtsen <larsi@gnus.org> 92010-10-14 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 10
3 * nnimap.el (nnimap-open-connection): Message when opening connection 11 * nnimap.el (nnimap-open-connection): Message when opening connection
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 4d70a62ac50..0ebd60c7543 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -218,20 +218,35 @@ redirects somewhere else."
218 ;; starts. 218 ;; starts.
219 (unless shr-start 219 (unless shr-start
220 (setq shr-start (point))) 220 (setq shr-start (point)))
221 ;; No space is needed before or after a breakable character or
222 ;; at the beginning of a line.
223 (when (and (eq (preceding-char) ? )
224 (or (= (line-beginning-position) (1- (point)))
225 (aref fill-find-break-point-function-table
226 (char-after (- (point) 2)))
227 (aref fill-find-break-point-function-table
228 (aref elem 0))))
229 (delete-char -1))
221 (insert elem) 230 (insert elem)
222 (while (> (current-column) shr-width) 231 (while (> (current-column) shr-width)
223 (if (not (shr-find-fill-point)) 232 (unless (prog1
224 (insert "\n") 233 (shr-find-fill-point)
225 (delete-char 1) 234 (when (eq (preceding-char) ? )
226 (insert "\n") 235 (delete-char -1))
236 (insert "\n"))
227 (put-text-property (1- (point)) (point) 'shr-break t) 237 (put-text-property (1- (point)) (point) 'shr-break t)
228 (when (> shr-indentation 0) 238 ;; No space is needed at the beginning of a line.
229 (shr-indent)) 239 (if (eq (following-char) ? )
230 (end-of-line))) 240 (delete-char 1)))
241 (when (> shr-indentation 0)
242 (shr-indent))
243 (end-of-line))
231 (insert " ")) 244 (insert " "))
232 (unless (string-match "[ \t\n]\\'" text) 245 (unless (string-match "[ \t\n]\\'" text)
233 (delete-char -1)))))) 246 (delete-char -1))))))
234 247
248(eval-and-compile (autoload 'kinsoku-longer "kinsoku"))
249
235(defun shr-find-fill-point () 250(defun shr-find-fill-point ()
236 (let ((found nil)) 251 (let ((found nil))
237 (while (and (not found) 252 (while (and (not found)
@@ -240,10 +255,26 @@ redirects somewhere else."
240 (aref fill-find-break-point-function-table 255 (aref fill-find-break-point-function-table
241 (preceding-char))) 256 (preceding-char)))
242 (<= (current-column) shr-width)) 257 (<= (current-column) shr-width))
243 (setq found (point))) 258 (setq found t))
244 (backward-char 1)) 259 (backward-char 1)
245 (or found 260 (when (bolp)
246 (end-of-line)))) 261 ;; There's no breakable point, so we give it up.
262 (end-of-line)
263 (while (aref fill-find-break-point-function-table
264 (preceding-char))
265 (backward-char 1))
266 (setq found 'failed)))
267 (cond ((eq found t)
268 ;; Don't put kinsoku-bol characters at the beginning of a line.
269 (or (eobp)
270 (kinsoku-longer)
271 (not (aref fill-find-break-point-function-table
272 (following-char)))
273 (forward-char 1)))
274 (found t)
275 (t
276 (end-of-line)
277 nil))))
247 278
248(defun shr-ensure-newline () 279(defun shr-ensure-newline ()
249 (unless (zerop (current-column)) 280 (unless (zerop (current-column))