aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Olum2017-10-09 16:54:00 +0300
committerEli Zaretskii2017-10-09 16:54:00 +0300
commit7ed73608559c2254ac66cf440f6f9eec934c4dae (patch)
treed476b4353f22a3ca65fe59f17a8dceaf28a7738f
parentaca5f0072b531d9621b0ff90e656e589281c8155 (diff)
downloademacs-7ed73608559c2254ac66cf440f6f9eec934c4dae.tar.gz
emacs-7ed73608559c2254ac66cf440f6f9eec934c4dae.zip
Fix problems when editing raw undecoded message (Bug#28671)
* lisp/mail/rmailedit.el (rmail-cease-edit): If rmail-old-mime-state is set, meaning that we are editing the raw message, do not encode it again. Delete old body after, not before, inserting new, to avoid moving marker at beginning of next message.
-rw-r--r--lisp/mail/rmailedit.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el
index b91a81503e2..640febd0473 100644
--- a/lisp/mail/rmailedit.el
+++ b/lisp/mail/rmailedit.el
@@ -312,26 +312,34 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
312 (data-buffer (current-buffer)) 312 (data-buffer (current-buffer))
313 (start (copy-marker (point) nil)) ; new body will be between 313 (start (copy-marker (point) nil)) ; new body will be between
314 (end (copy-marker (point) t))) ; these two markers 314 (end (copy-marker (point) t))) ; these two markers
315 (with-current-buffer rmail-view-buffer 315 (if mime-state
316 (encode-coding-region headers-end (point-max) coding-system 316 ;; Message is already in encoded state
317 data-buffer)) 317 (insert-buffer-substring rmail-view-buffer headers-end
318 (delete-region end (point-max)) 318 (with-current-buffer rmail-view-buffer
319 (point-max)))
320 (with-current-buffer rmail-view-buffer
321 (encode-coding-region headers-end (point-max) coding-system
322 data-buffer)))
319 ;; Apply to the mbox buffer any changes in header fields 323 ;; Apply to the mbox buffer any changes in header fields
320 ;; that the user made while editing in the view buffer. 324 ;; that the user made while editing in the view buffer.
321 (rmail-edit-update-headers (rmail-edit-diff-headers 325 (rmail-edit-update-headers (rmail-edit-diff-headers
322 rmail-old-headers new-headers)) 326 rmail-old-headers new-headers))
323 ;; Re-apply content-transfer-encoding, if any, on the message body. 327 ;; Re-apply content-transfer-encoding, if any, on the message body.
324 (cond 328 (cond
329 (mime-state) ; if set, already transfer-encoded
325 ((string= character-coding "quoted-printable") 330 ((string= character-coding "quoted-printable")
326 (mail-quote-printable-region start (point-max))) 331 (mail-quote-printable-region start end))
327 ((and (string= character-coding "base64") is-text-message) 332 ((and (string= character-coding "base64") is-text-message)
328 (base64-encode-region start (point-max))) 333 (base64-encode-region start end))
329 ((and (eq character-coding 'uuencode) is-text-message) 334 ((and (eq character-coding 'uuencode) is-text-message)
330 (error "uuencoded messages are not supported"))) 335 (error "uuencoded messages are not supported")))
331 ;; After encoding, make sure buffer ends with a blank line so as not to 336 ;; After encoding, make sure buffer ends with a blank line so as not to
332 ;; run this message together with the following one. 337 ;; run this message together with the following one.
333 (goto-char (point-max)) 338 (goto-char end)
334 (rmail-ensure-blank-line)) 339 (rmail-ensure-blank-line)
340 ;; Delete previous body. This must be after all insertions at the end,
341 ;; so the marker for the beginning of the next message isn't messed up.
342 (delete-region end (point-max)))
335 (rmail-set-attribute rmail-edited-attr-index t)) 343 (rmail-set-attribute rmail-edited-attr-index t))
336;;;??? BROKEN perhaps. 344;;;??? BROKEN perhaps.
337;;; (if (boundp 'rmail-summary-vector) 345;;; (if (boundp 'rmail-summary-vector)