]> git.eshelyaron.com Git - emacs.git/commitdiff
(rmail-cease-edit): narrow-to-region before extracting mail message headers.
authorEli Zaretskii <eliz@gnu.org>
Sat, 7 Feb 2009 12:55:49 +0000 (12:55 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 7 Feb 2009 12:55:49 +0000 (12:55 +0000)
Use encode-coding-region instead of insert-buffer-substring for re-encoding
edited message.  Add qp/b64 encoding only after text was encoded.

lisp/ChangeLog
lisp/mail/rmailedit.el

index 9c8d91dd618ee01f5b4a8836006843fdfdc30a71..1c3db798cba66c401ac8a2d0acae5dff08d8c3d5 100644 (file)
@@ -1,3 +1,10 @@
+2009-02-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * mail/rmailedit.el (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.
+
 2009-02-07  Eli Zaretskii  <eliz@gnu.org>
 
        * subr.el: Don't declare `translation-table-for-input' obsolete.
index 86ffdc9d2f67cda08e694910a6dab05edd08d948..44f749fdc0590b93c607a9b121f5bbe4636224ba 100644 (file)
@@ -145,38 +145,38 @@ This functions runs the normal hook `rmail-edit-mode-hook'.
 
       (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)