Mercurial > emacs
comparison lisp/gnus/shr.el @ 111021:7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Mon, 18 Oct 2010 05:21:26 +0000 |
parents | 615617bd614d |
children | d263303441df |
comparison
equal
deleted
inserted
replaced
111020:9d2f59f15c3e | 111021:7aa9d9b402c8 |
---|---|
201 (setq shr-state nil)) | 201 (setq shr-state nil)) |
202 (cond | 202 (cond |
203 ((eq shr-folding-mode 'none) | 203 ((eq shr-folding-mode 'none) |
204 (insert text)) | 204 (insert text)) |
205 (t | 205 (t |
206 (let ((first t) | 206 (when (and (string-match "\\`[ \t\n]" text) |
207 column) | 207 (not (bolp)) |
208 (when (and (string-match "\\`[ \t\n]" text) | 208 (not (eq (char-after (1- (point))) ? ))) |
209 (not (bolp)) | 209 (insert " ")) |
210 (not (eq (char-after (1- (point))) ? ))) | 210 (dolist (elem (split-string text)) |
211 (insert " ")) | 211 (when (and (bolp) |
212 (dolist (elem (split-string text)) | 212 (> shr-indentation 0)) |
213 (when (and (bolp) | 213 (shr-indent)) |
214 (> shr-indentation 0)) | 214 ;; The shr-start is a special variable that is used to pass |
215 (shr-indent)) | 215 ;; upwards the first point in the buffer where the text really |
216 ;; The shr-start is a special variable that is used to pass | 216 ;; starts. |
217 ;; upwards the first point in the buffer where the text really | 217 (unless shr-start |
218 ;; starts. | 218 (setq shr-start (point))) |
219 (unless shr-start | 219 ;; No space is needed behind a wide character categorized as |
220 (setq shr-start (point))) | 220 ;; kinsoku-bol, or between characters both categorized as nospace. |
221 ;; No space is needed before or after a breakable character or | 221 (let (prev) |
222 ;; at the beginning of a line. | |
223 (when (and (eq (preceding-char) ? ) | 222 (when (and (eq (preceding-char) ? ) |
224 (or (= (line-beginning-position) (1- (point))) | 223 (or (= (line-beginning-position) (1- (point))) |
225 (aref fill-find-break-point-function-table | 224 (and (aref fill-find-break-point-function-table |
226 (char-after (- (point) 2))) | 225 (setq prev (char-after (- (point) 2)))) |
227 (aref fill-find-break-point-function-table | 226 (aref (char-category-set prev) ?>)) |
228 (aref elem 0)))) | 227 (and (aref fill-nospace-between-words-table prev) |
229 (delete-char -1)) | 228 (aref fill-nospace-between-words-table |
230 (insert elem) | 229 (aref elem 0))))) |
231 (while (> (current-column) shr-width) | 230 (delete-char -1))) |
232 (unless (prog1 | 231 (insert elem) |
233 (shr-find-fill-point) | 232 (while (> (current-column) shr-width) |
234 (when (eq (preceding-char) ? ) | 233 (unless (prog1 |
235 (delete-char -1)) | 234 (shr-find-fill-point) |
236 (insert "\n")) | 235 (when (eq (preceding-char) ? ) |
237 (put-text-property (1- (point)) (point) 'shr-break t) | 236 (delete-char -1)) |
238 ;; No space is needed at the beginning of a line. | 237 (insert "\n")) |
239 (if (eq (following-char) ? ) | 238 (put-text-property (1- (point)) (point) 'shr-break t) |
240 (delete-char 1))) | 239 ;; No space is needed at the beginning of a line. |
241 (when (> shr-indentation 0) | 240 (if (eq (following-char) ? ) |
242 (shr-indent)) | 241 (delete-char 1))) |
243 (end-of-line)) | 242 (when (> shr-indentation 0) |
244 (insert " ")) | 243 (shr-indent)) |
245 (unless (string-match "[ \t\n]\\'" text) | 244 (end-of-line)) |
246 (delete-char -1)))))) | 245 (insert " ")) |
246 (unless (string-match "[ \t\n]\\'" text) | |
247 (delete-char -1))))) | |
247 | 248 |
248 (eval-and-compile (autoload 'kinsoku-longer "kinsoku")) | 249 (eval-and-compile (autoload 'kinsoku-longer "kinsoku")) |
249 | 250 |
250 (defun shr-find-fill-point () | 251 (defun shr-find-fill-point () |
251 (let ((found nil)) | 252 (let ((found nil)) |