(message-narrow-to-headers)
(let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
(cur (current-buffer))
+ (encoded-cache message-encoded-mail-cache)
groups group method group-art options
mml-externalize-attachments)
(when gcc
(setq message-options (with-current-buffer cur message-options))
(insert-buffer-substring cur)
(run-hooks 'gnus-gcc-pre-body-encode-hook)
- (message-encode-message-body)
+ ;; Avoid re-doing things like GPG-encoding secret parts.
+ (if (not encoded-cache)
+ (message-encode-message-body)
+ (erase-buffer)
+ (insert encoded-cache))
+ (message-remove-header "gcc")
(run-hooks 'gnus-gcc-post-body-encode-hook)
(save-restriction
(message-narrow-to-headers)
(defvar message-bogus-system-names "\\`localhost\\.\\|\\.local\\'"
"The regexp of bogus system names.")
+(defvar message-encoded-mail-cache nil
+ "After sending a message, the encoded version is cached in this variable.")
+
(autoload 'gnus-alive-p "gnus-util")
(autoload 'gnus-delay-article "gnus-delay")
(autoload 'gnus-extract-address-components "gnus-util")
;; excluding citations and other artifacts.
;;
(set (make-local-variable 'syntax-propertize-function) 'message--syntax-propertize)
- (set (make-local-variable 'parse-sexp-ignore-comments) t))
+ (set (make-local-variable 'parse-sexp-ignore-comments) t)
+ (setq-local message-encoded-mail-cache nil))
(defun message-setup-fill-variables ()
"Setup message fill variables."
(mml-buffer-substring-no-properties-except-some
(point-min) (point-max))))
(message-encode-message-body)
+ (message--cache-encoded mailbuf)
(save-restriction
(message-narrow-to-headers)
;; We (re)generate the Lines header.
(setq message-options options)
(push 'mail message-sent-message-via)))
+(defun message--cache-encoded (mailbuf)
+ ;; Store the encoded buffer data for possible reuse later
+ ;; when doing Fcc/Gcc handling. This avoids having to do
+ ;; things like re-GPG-encoding secure parts.
+ (let ((encoded (buffer-string)))
+ (with-current-buffer mailbuf
+ (setq message-encoded-mail-cache encoded))))
+
(defun message--fold-long-headers ()
"Fold too-long header lines.
Each line should be no more than 79 characters long."
(mml-buffer-substring-no-properties-except-some
(point-min) (point-max))))
(message-encode-message-body)
+ (message--cache-encoded messbuf)
;; Remove some headers.
(save-restriction
(message-narrow-to-headers)
"Process Fcc headers in the current buffer."
(let ((case-fold-search t)
(buf (current-buffer))
+ (encoded-cache message-encoded-mail-cache)
(mml-externalize-attachments message-fcc-externalize-attachments)
(file (message-field-value "fcc" t))
list)
(with-temp-buffer
(insert-buffer-substring buf)
(message-clone-locals buf)
- (message-encode-message-body)
+ ;; Avoid re-doing things like GPG-encoding secret parts.
+ (if (not encoded-cache)
+ (message-encode-message-body)
+ (erase-buffer)
+ (insert encoded-cache))
(save-restriction
(message-narrow-to-headers)
(while (setq file (message-fetch-field "fcc" t))