comparison lisp/mail/rmailedit.el @ 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 b87c9a6e8490
children cf870c811594
comparison
equal deleted inserted replaced
101866:b05303a22a91 101867:07f6502ced98
143 (search-forward "\n\n") 143 (search-forward "\n\n")
144 (setq headers-end (point)) 144 (setq headers-end (point))
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)
183 ;;; (progn 183 ;;; (progn
184 ;;; (aset rmail-summary-vector (1- rmail-current-message) nil) 184 ;;; (aset rmail-summary-vector (1- rmail-current-message) nil)