bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4623: 23.1.50; rmail changes encoding of characters on save


From: Eli Zaretskii
Subject: bug#4623: 23.1.50; rmail changes encoding of characters on save
Date: Sat, 05 Dec 2009 14:03:29 +0200

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: 4623@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)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]