changeset 101867:07f6502ced98

(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.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 07 Feb 2009 12:54:35 +0000
parents b05303a22a91
children 8e0a2c5ca456
files lisp/mail/rmailedit.el
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmailedit.el	Sat Feb 07 11:48:40 2009 +0000
+++ b/lisp/mail/rmailedit.el	Sat Feb 07 12:54:35 2009 +0000
@@ -145,38 +145,38 @@
 
       (rmail-swap-buffers-maybe)
 
+      (narrow-to-region (rmail-msgbeg rmail-current-message)
+                       (rmail-msgend rmail-current-message))
+
       (setq character-coding (mail-fetch-field "content-transfer-encoding")
 	    is-text-message (rmail-is-text-p)
 	    coding-system (rmail-get-coding-system))
       (if character-coding
 	  (setq character-coding (downcase character-coding)))
 
-      (narrow-to-region (rmail-msgbeg rmail-current-message)
-			(rmail-msgend rmail-current-message))
       (goto-char (point-min))
       (search-forward "\n\n")
-      (let ((inhibit-read-only t)
-	    (headers-end-1 (point)))
-	(insert-buffer-substring rmail-view-buffer headers-end)
-	(delete-region (point) (point-max))
+      (let ((inhibit-read-only t))
+	(let ((data-buffer (current-buffer))
+	      (end (copy-marker (point) t)))
+	  (with-current-buffer rmail-view-buffer
+	    (encode-coding-region headers-end (point-max) coding-system
+				  data-buffer))
+	  (delete-region end (point-max)))
 
 	;; Re-encode the message body in whatever
 	;; way it was decoded.
 	(cond
 	 ((string= character-coding "quoted-printable")
-	  (mail-quote-printable-region headers-end-1 (point-max)))
+	  (mail-quote-printable-region (point) (point-max)))
 	 ((and (string= character-coding "base64") is-text-message)
-	  (base64-encode-region headers-end-1 (point-max)))
+	  (base64-encode-region (point) (point-max)))
 	 ((eq character-coding 'uuencode)
-	  (error "Not supported yet."))
-	 (t
-	  (if (or (not coding-system) (not (coding-system-p coding-system)))
-	      (setq coding-system 'undecided))
-	  (encode-coding-region headers-end-1 (point-max) coding-system)))
+	  (error "uuencoded messages are not supported yet.")))
 	))
 
     (rmail-set-attribute rmail-edited-attr-index t)
-	
+
     ;;??? BROKEN perhaps.
     ;; I think that the Summary-Line header may not be kept there any more.
 ;;;       (if (boundp 'rmail-summary-vector)