GNU bug report logs -
#4623
23.1.50; rmail changes encoding of characters on save
Previous Next
Full log
Message #55 received at 4623 <at> emacsbugs.donarmstrong.com (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: 4623 <at> emacsbugs.donarmstrong.com
> Date: Fri, 04 Dec 2009 14:48:41 -0500
>
> Oh, I see, it's because setting coding-system-for-write affect the
> buffer-file-coding-system choice which is later saved into the
> "original" buffer, which in this case is the displayed buffer.
Yes.
> Let's take a step back: when/why does buffer-file-coding-system matter
> in the RMAIL display buffer?
Several reasons off the top of my head:
. It gives you an easily visible indication of how the message was
encoded. (We hide the relevant mail headers by default, so they
are not visible unless you invoke rmail-toggle-header.)
. It is useful when saving the current message to a file.
. When replying to a message, rmail-reply uses it to set the
encoding of the *mail* buffer where you compose the reply, which
takes care of 99.99% of situations where the response needs to
have some non-trivial encoding that is not your system's native
one.
The last one of these is by far the most important reason, at least in
my use pattern.
Maybe we need to set up an after-save-hook to restore the original
encoding after saving the message collection?
Btw, I find rmail-swap-buffers incomplete in its handling of encoding
and the modified flag. It looks like it works by sheer luck, unless
I'm missing something. I suggest the following more thorough version.
If nothing else, it eliminates the need for the kludge in
rmail-write-region-annotate that forces no-conversion at save-buffer
time (because the encoding of the message collection buffer is now
kept at no-conversion at all times):
(defun rmail-swap-buffers ()
"Swap text between current buffer and `rmail-view-buffer'.
This function preserves the buffers' modified flags, and also
swaps the current buffer's `buffer-file-coding-system' with that
of `rmail-view-buffer'."
(let ((modp-this (buffer-modified-p))
(modp-that
(with-current-buffer rmail-view-buffer (buffer-modified-p)))
(coding-this buffer-file-coding-system)
(coding-that
(with-current-buffer rmail-view-buffer
buffer-file-coding-system)))
(buffer-swap-text rmail-view-buffer)
(setq buffer-file-coding-system coding-that)
(with-current-buffer rmail-view-buffer
(setq buffer-file-coding-system coding-this)
(restore-buffer-modified-p modp-that))
(restore-buffer-modified-p modp-this)))
This bug report was last modified 15 years and 166 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.