aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2009-02-07 12:55:49 +0000
committerEli Zaretskii2009-02-07 12:55:49 +0000
commitaaaaa2767d1a58d8d667eb9c9bf14539b817f39b (patch)
tree275d4031bdce506eaed075d75e334f1e379faf99
parent7d2a859fabcea25051efff5bc6fec78b7290c2b6 (diff)
downloademacs-aaaaa2767d1a58d8d667eb9c9bf14539b817f39b.tar.gz
emacs-aaaaa2767d1a58d8d667eb9c9bf14539b817f39b.zip
(rmail-cease-edit): narrow-to-region before extracting mail message headers.
Use encode-coding-region instead of insert-buffer-substring for re-encoding edited message. Add qp/b64 encoding only after text was encoded.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/mail/rmailedit.el28
2 files changed, 21 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9c8d91dd618..1c3db798cba 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12009-02-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * mail/rmailedit.el (rmail-cease-edit): narrow-to-region before
4 extracting mail message headers. Use encode-coding-region instead
5 of insert-buffer-substring for re-encoding edited message. Add
6 qp/b64 encoding only after text was encoded.
7
12009-02-07 Eli Zaretskii <eliz@gnu.org> 82009-02-07 Eli Zaretskii <eliz@gnu.org>
2 9
3 * subr.el: Don't declare `translation-table-for-input' obsolete. 10 * subr.el: Don't declare `translation-table-for-input' obsolete.
diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el
index 86ffdc9d2f6..44f749fdc05 100644
--- a/lisp/mail/rmailedit.el
+++ b/lisp/mail/rmailedit.el
@@ -145,38 +145,38 @@ This functions runs the normal hook `rmail-edit-mode-hook'.
145 145
146 (rmail-swap-buffers-maybe) 146 (rmail-swap-buffers-maybe)
147 147
148 (narrow-to-region (rmail-msgbeg rmail-current-message)
149 (rmail-msgend rmail-current-message))
150
148 (setq character-coding (mail-fetch-field "content-transfer-encoding") 151 (setq character-coding (mail-fetch-field "content-transfer-encoding")
149 is-text-message (rmail-is-text-p) 152 is-text-message (rmail-is-text-p)
150 coding-system (rmail-get-coding-system)) 153 coding-system (rmail-get-coding-system))
151 (if character-coding 154 (if character-coding
152 (setq character-coding (downcase character-coding))) 155 (setq character-coding (downcase character-coding)))
153 156
154 (narrow-to-region (rmail-msgbeg rmail-current-message)
155 (rmail-msgend rmail-current-message))
156 (goto-char (point-min)) 157 (goto-char (point-min))
157 (search-forward "\n\n") 158 (search-forward "\n\n")
158 (let ((inhibit-read-only t) 159 (let ((inhibit-read-only t))
159 (headers-end-1 (point))) 160 (let ((data-buffer (current-buffer))
160 (insert-buffer-substring rmail-view-buffer headers-end) 161 (end (copy-marker (point) t)))
161 (delete-region (point) (point-max)) 162 (with-current-buffer rmail-view-buffer
163 (encode-coding-region headers-end (point-max) coding-system
164 data-buffer))
165 (delete-region end (point-max)))
162 166
163 ;; Re-encode the message body in whatever 167 ;; Re-encode the message body in whatever
164 ;; way it was decoded. 168 ;; way it was decoded.
165 (cond 169 (cond
166 ((string= character-coding "quoted-printable") 170 ((string= character-coding "quoted-printable")
167 (mail-quote-printable-region headers-end-1 (point-max))) 171 (mail-quote-printable-region (point) (point-max)))
168 ((and (string= character-coding "base64") is-text-message) 172 ((and (string= character-coding "base64") is-text-message)
169 (base64-encode-region headers-end-1 (point-max))) 173 (base64-encode-region (point) (point-max)))
170 ((eq character-coding 'uuencode) 174 ((eq character-coding 'uuencode)
171 (error "Not supported yet.")) 175 (error "uuencoded messages are not supported yet.")))
172 (t
173 (if (or (not coding-system) (not (coding-system-p coding-system)))
174 (setq coding-system 'undecided))
175 (encode-coding-region headers-end-1 (point-max) coding-system)))
176 )) 176 ))
177 177
178 (rmail-set-attribute rmail-edited-attr-index t) 178 (rmail-set-attribute rmail-edited-attr-index t)
179 179
180 ;;??? BROKEN perhaps. 180 ;;??? BROKEN perhaps.
181 ;; I think that the Summary-Line header may not be kept there any more. 181 ;; I think that the Summary-Line header may not be kept there any more.
182;;; (if (boundp 'rmail-summary-vector) 182;;; (if (boundp 'rmail-summary-vector)