comparison lisp/gnus/flow-fill.el @ 112108:c24551a0cd95

flow-fill.el (fill-flowed-encode): Do encoding citation-aware. gnus-art.el (gnus-treat-fill-long-lines): Add missing version tag. gnus-msg.el (gnus-message-replyencrypt): Fix typo in version string.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 04 Jan 2011 02:24:15 +0000
parents f2e111723c3a
children 417b1e4d63cd
comparison
equal deleted inserted replaced
112107:c2f0548dd4e6 112108:c24551a0cd95
1 ;;; flow-fill.el --- interpret RFC2646 "flowed" text 1 ;;; flow-fill.el --- interpret RFC2646 "flowed" text
2 2
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 ;; 2009, 2010, 2011 Free Software Foundation, Inc.
5 5
6 ;; Author: Simon Josefsson <jas@pdc.kth.se> 6 ;; Author: Simon Josefsson <jas@pdc.kth.se>
7 ;; Keywords: mail 7 ;; Keywords: mail
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
80 (when use-hard-newlines 80 (when use-hard-newlines
81 (let ((start (point-min)) end) 81 (let ((start (point-min)) end)
82 ;; Go through each paragraph, filling it and adding SPC 82 ;; Go through each paragraph, filling it and adding SPC
83 ;; as the last character on each line. 83 ;; as the last character on each line.
84 (while (setq end (text-property-any start (point-max) 'hard 't)) 84 (while (setq end (text-property-any start (point-max) 'hard 't))
85 (let ((fill-column (eval fill-flowed-encode-column))) 85 (save-restriction
86 (fill-region start end t 'nosqueeze 'to-eop)) 86 (narrow-to-region start end)
87 (goto-char start) 87 (let ((fill-column (eval fill-flowed-encode-column)))
88 ;; `fill-region' probably distorted end. 88 (fill-flowed-fill-buffer))
89 (setq end (text-property-any start (point-max) 'hard 't)) 89 (goto-char (point-min))
90 (while (and (< (point) end) 90 (while (re-search-forward "\n" nil t)
91 (re-search-forward "$" (1- end) t)) 91 (replace-match " \n" t t))
92 (insert " ") 92 (goto-char (setq start (1+ (point-max)))))))
93 (setq end (1+ end))
94 (forward-char))
95 (goto-char (setq start (1+ end)))))
96 t))) 93 t)))
94
95 (defun fill-flowed-fill-buffer ()
96 (let ((prefix nil)
97 (prev-prefix nil)
98 (start (point-min)))
99 (goto-char (point-min))
100 (while (not (eobp))
101 (setq prefix (and (looking-at "[> ]+")
102 (match-string 0)))
103 (if (equal prefix prev-prefix)
104 (forward-line 1)
105 (save-restriction
106 (narrow-to-region start (point))
107 (let ((fill-prefix prev-prefix))
108 (fill-region (point-min) (point-max) t 'nosqueeze 'to-eop))
109 (goto-char (point-max)))
110 (setq prev-prefix prefix
111 start (point))))
112 (save-restriction
113 (narrow-to-region start (point))
114 (let ((fill-prefix prev-prefix))
115 (fill-region (point-min) (point-max) t 'nosqueeze 'to-eop)))))
97 116
98 ;;;###autoload 117 ;;;###autoload
99 (defun fill-flowed (&optional buffer delete-space) 118 (defun fill-flowed (&optional buffer delete-space)
100 (with-current-buffer (or (current-buffer) buffer) 119 (with-current-buffer (or (current-buffer) buffer)
101 (goto-char (point-min)) 120 (goto-char (point-min))