unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4623: 23.1.50; rmail changes encoding of characters on save
@ 2009-12-04 16:36 Eli Zaretskii
  2009-12-04 17:16 ` Glenn Morris
  2009-12-04 18:42 ` Stefan Monnier
  0 siblings, 2 replies; 27+ messages in thread
From: Eli Zaretskii @ 2009-12-04 16:36 UTC (permalink / raw)
  To: 4623

The cure for this bug, viz.

  *** rmail.el   6 Oct 2009 06:40:40 -0000  1.554
  --- rmail.el   13 Oct 2009 01:17:20 -0000
  ***************
  *** 4176,4181 ****
  --- 4176,4182 ----
    (defun rmail-write-region-annotate (start end)
      (when (and (null start) (rmail-buffers-swapped-p))
        (set-buffer rmail-view-buffer)
  +     (set (make-local-variable 'coding-system-for-write) 'no-conversion)
        (widen)
        nil))

is IMO not much better than the disease: now C-x C-s _always_ leaves
the RMAIL buffer in no-conversion state, until you display a message,
e.g., with "M-n".

I think this happens because the above sets the encoding of
rmail-view-buffer, where we display the messages, to no-conversion.

I'm not sure how to solve this.  What is needed is bind
coding-system-for-write to no-conversion just for the duration of
save-buffer or write-region that it calls eventually.  But because we
use annotations to switch the buffer behind save-buffer's back,
there's no easy way of doing that.

Perhaps we should special-case RMAIL in save-buffer, or maybe do
something in buffer-swap-text.

Any ideas are welcome.  If no better idea pops up very soon, I suggest
the following band-aid for Emacs 23.2:

  . don't set coding-system-for-write in rmail-write-region-annotate

  . bind C-x C-s in Rmail mode to a special command, like rmail-save,
    which will bind coding-system-for-write to no-conversion

  . wrap all instances of save-buffer in Rmail with a form that
    let-binds coding-system-for-write to no-conversion

This will at least plumb the problem in 99% of use cases, I think.





^ permalink raw reply	[flat|nested] 27+ messages in thread
* bug#4623: 23.1.50; rmail changes encoding of characters on save
@ 2009-10-03 14:54 Markus Rost
  2009-10-13  1:21 ` Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Markus Rost @ 2009-10-03 14:54 UTC (permalink / raw)
  To: emacs-pretest-bug


With rmail I observed random encoding changes in mbox files:  some
non-ascii characters are changed depending on which message you look
at while saving.

Providing a test case is a bit tiresome, so I omit one for now.

The reason for the problem is that rmail-expunge-and-save uses the
coding system of the current message when saving the file.  This is
certainly wrong:  the coding system for writing the mbox file must not
depend on the currently selected message.

Since rmail reads the mbox file with coding-system 'no-conversion, it
should save it with coding-system 'no-conversion.

Perhaps the problem sits in rmail-swap-buffers:  Shouldn't
rmail-swap-buffers exchange the value of buffer-file-coding-system in
both ways?  Or perhaps it should ensure that the buffer which contains
the full mbox file has always the same buffer-file-coding-system,
namely 'no-conversion.

Anyway, the following ad hoc patch fixes the problem for me.

*** rmail.el.~1.552.~	2009-09-26 21:21:07.000000000 +0200
--- rmail.el	2009-10-02 16:14:30.000000000 +0200
***************
*** 1458,1464 ****
    (rmail-expunge)
    ;; No need to swap buffers: rmail-write-region-annotate takes care of it.
    ;; (rmail-swap-buffers-maybe)
!   (save-buffer)
    (if (rmail-summary-exists)
        (rmail-select-summary (set-buffer-modified-p nil))))
  
--- 1458,1465 ----
    (rmail-expunge)
    ;; No need to swap buffers: rmail-write-region-annotate takes care of it.
    ;; (rmail-swap-buffers-maybe)
!   (let ((coding-system-for-write 'no-conversion))
!     (save-buffer))
    (if (rmail-summary-exists)
        (rmail-select-summary (set-buffer-modified-p nil))))


In GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.16.1)
 of 2009-10-02 on laptop
Windowing system distributor `The X.Org Foundation', version 11.0.10600000
configured using `configure  '--prefix=/home/rost/local/cvs''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t





^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2009-12-08 13:47 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-04 16:36 bug#4623: 23.1.50; rmail changes encoding of characters on save Eli Zaretskii
2009-12-04 17:16 ` Glenn Morris
2009-12-04 18:42 ` Stefan Monnier
2009-12-04 19:15   ` Eli Zaretskii
2009-12-04 19:48     ` Stefan Monnier
2009-12-05 12:03       ` Eli Zaretskii
2009-12-05 20:10         ` Markus Rost
2009-12-05 21:52           ` Eli Zaretskii
2009-12-05 22:37             ` Markus Rost
2009-12-06  4:10               ` Eli Zaretskii
2009-12-06 14:40                 ` Markus Rost
2009-12-06 19:17             ` Eli Zaretskii
2009-12-06 20:23               ` Markus Rost
2009-12-07  4:04                 ` Eli Zaretskii
2009-12-07 19:22                   ` Eli Zaretskii
2009-12-07 19:50                     ` Markus Rost
2009-12-07 19:51                       ` Eli Zaretskii
2009-12-07  4:34         ` Stefan Monnier
2009-12-07 18:59           ` Eli Zaretskii
2009-12-07 19:25             ` Stefan Monnier
2009-12-07 19:53               ` Eli Zaretskii
2009-12-07 21:44                 ` Stefan Monnier
2009-12-08  4:14                   ` Eli Zaretskii
2009-12-08 13:47                     ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2009-10-03 14:54 Markus Rost
2009-10-13  1:21 ` Glenn Morris
2009-10-13  2:16   ` Markus Rost

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).