Subject: Re: bug#28266: 25.2; RMAIL FCC coding issue

From: [email-masked] (Charles A. Roelli)
Date: Sun, 24 Sep 2017 10:47:29 +0200

> Date: Fri, 22 Sep 2017 23:08:13 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > Date: Fri, 22 Sep 2017 20:39:45 +0200
> > From: [email-masked] (Charles A. Roelli)
> > CC: [email-masked]
> > 
> > > Date: Fri, 22 Sep 2017 16:13:58 +0300
> > > From: Eli Zaretskii <[email-masked]>
> > > 
> > > I cannot reproduce this with the current emacs-26 branch tip.
> > > However, in my case, Emacs asked for a suitable coding-system each
> > > time I wanted to send a message.  Answering UTF-8 produced a valid
> > > encoding in both cases.
> > > 
> > > So perhaps the difference, and the reason for a problem you see, is
> > > the default encoding in your case, which you didn't show.  (In my
> > > case, the default is Latin-1.)
> > 
> > Hmm, I was never queried for a coding system.
> 
> Because your default is UTF-8.  This is normal.
> 
> > I've repeated the issue on GNU/Linux with 25.3 and macOS with 25.3
> > and emacs-26.  And I don't set any special locales/language
> > environments:
> > 
> > > Important settings:
> > >   value of $LANG: en_GB.UTF-8
> > >   locale-coding-system: utf-8-unix
> 
> With en_US.UTF-8 on GNU/Linux, using the current emacs-26 branch, I
> see no problem: both messages are sent with a correct encoding.

Yes, I believe that in my case too, the messages are (or would be)
sent with the correct encoding.  The encoding issue I mentioned seems
to only apply to the saving of the mail buffer into the file specified
in the FCC header.

> What happens if you don't visit the FCC file after the first message
> is sent, only after the second?  Do you still see the second message
> encoded incorrectly?

No, in that case, both messages are encoded correctly.  The encoding
issue seems to only occur when the buffer is already open.

The text of the outgoing mail buffer is inserted into the file
specified by the FCC header using "insert-buffer-substring" in
function "rmail-output-to-rmail-buffer" (use C-u C-M-x on this
function before hitting C-c C-c y to resend the mail).  If you switch
to "tembuf" (argument to "rmail-output-to-rmail-buffer") in another
frame while debugging this function, you can see in the modeline that
its coding system is utf-8-unix.  Then if you switch to the buffer
containing the FCC file, the modeline indicates that it's unibyte.

Note also that variable "enable-multibyte-characters" is bound to nil
around this call.