Subject: bug#20133: 24.4; message-mode signs mails multiple times for FCC

From: Moritz Ulrich <[email-masked]>
Date: Wed, 18 Mar 2015 12:41:34 +0100

When sending signed emails with `mml-secure-message-sign-pgpmime', GnuPG
is called once for the outgoing mail, then again for every FCC: header
field.

This isn't problematic when using gpg-agent & caching of
passphrases, very annoying when not. 

A failure when typing the passphrase a second time results in message
failing to store a local copy of the mail, even when the mail was sent
successfully. This can be confusing.

The issue tracks down to message.el:5411 where
`message-encode-message-body' is called in a loop for every FCC.

I'm not sure why it's necessary to re-encode the message once for every
FCC. Isn't it possible to just store the original outgoing mail?

If not, I suggest adding a variable to prevent signing from happening
when storing the mail locally. 

In GNU Emacs 24.4.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.25)
 of 2015-02-20 on localhost
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
Configured using:
 `configure --disable-dependency-tracking
 --prefix=/nix/store/ji06y4haijly0i0knmr986l2dajffv1p-emacs-24.4
 --with-x-toolkit=gtk --with-xft'

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Message

Minor modes in effect:
  mml-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  auto-fill-function: message-do-auto-fill
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
C-x m m o r i t z @ t r <backspace> a r n - v e d r 
a . d e C-j C-/ C-n t e s t C-j F C C : S-SPC / h o 
m e / m o r i t z / <M-backspace> <M-backspace> t m 
p / C-n C-n C-e C-j C-j M-x m m l <XF86Tools> - <tab> 
<tab> s e <tab> e <tab> <M-backspace> <tab> i <backspace> 
s i <tab> <tab> - p g <tab> m <tab> <return> C-/ M-x 
m m <tab> l - s e <tab> <M-backspace> m e <tab> <tab> 
<M-backspace> s <tab> m <tab> <tab> s i <tab> - <tab> 
m <backspace> p <backspace> p g p m <tab> <return> 
C-c C-c t r <tab> <return> M-x C-g M-x r e p o r t 
a <backspace> - e m <tab> <return>

Recent messages:
Undo!
Making completion list... [3 times]
You can run the command `mml-secure-message-sign-pgpmime' with C-c RET s p
Mark set
Sending...
Mark set [2 times]
Sending via mail...
Setting `send-mail-function' temporarily since "emacs -q" would overwrite customizations
Mark set
mail-file-babyl-p: not a regular file: /tmp/
Quit

Load-path shadows:
/run/current-system/sw/share/emacs/site-lisp/site-start hides /nix/store/ji06y4haijly0i0knmr986l2dajffv1p-emacs-24.4/share/emacs/site-lisp/site-start

Features:
(shadow emacsbug mailalias cus-edit cus-start cus-load sendmail epg gnus
gnus-ems nnheader wid-edit cl-loaddefs cl-lib mml2015 epg-config
password-cache mail-extr sort help-mode gnus-util message format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr
mailabbrev mail-utils gmm-utils mailheader time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 108724 11604)
 (symbols 48 20876 0)
 (miscs 40 111 160)
 (strings 32 17949 4123)
 (string-bytes 1 517079)
 (vectors 16 12380)
 (vector-slots 8 415807 7630)
 (floats 8 81 276)
 (intervals 56 381 20)
 (buffers 960 17)
 (heap 1024 29049 684))