GNU bug report logs -
#4623
23.1.50; rmail changes encoding of characters on save
Previous Next
Full log
Message #110 received at 4623 <at> emacsbugs.donarmstrong.com (full text, mbox):
> Date: Mon, 07 Dec 2009 06:04:34 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 4623 <at> emacsbugs.donarmstrong.com
>
> > From: Markus Rost <rost <at> math.uni-bielefeld.de>
> > CC: 4623 <at> emacsbugs.donarmstrong.com
> > Date: Sun, 6 Dec 2009 21:23:48 +0100 (CET)
> >
> > One minor thing: Since rmail-message-encoding is a global variable,
> > several Rmail buffers may interfere.
>
> Right, I didn't think abut that possibility. I will try to think
> about some simple solution.
I think I found it.
If we have to live with rmail-write-region-annotate, we might as well
have it do something useful:
Index: lisp/mail/rmail.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mail/rmail.el,v
retrieving revision 1.562
diff -u -r1.562 rmail.el
--- lisp/mail/rmail.el 4 Dec 2009 05:00:47 -0000 1.562
+++ lisp/mail/rmail.el 7 Dec 2009 19:14:23 -0000
@@ -1316,13 +1316,19 @@
This function preserves the current buffer's modified flag, and also
sets the current buffer's `buffer-file-coding-system' to that of
`rmail-view-buffer'."
- (let ((modp (buffer-modified-p))
- (coding
+ (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)
- (restore-buffer-modified-p modp)))
+ (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)))
(defun rmail-buffers-swapped-p ()
"Return non-nil if the message collection is in `rmail-view-buffer'."
@@ -4179,16 +4185,31 @@
(add-to-list 'desktop-buffer-mode-handlers
'(rmail-mode . rmail-restore-desktop-buffer))
+;; We use this to record the encoding of the current message before
+;; saving the message collection.
+(defvar rmail-message-encoding nil)
+
;; Used in `write-region-annotate-functions' to write rmail files.
(defun rmail-write-region-annotate (start end)
(when (and (null start) (rmail-buffers-swapped-p))
+ (setq rmail-message-encoding buffer-file-coding-system)
(set-buffer rmail-view-buffer)
- ;; Prevent viewing different messages from messing up the coding. (Bug#4623)
- ;; FIXME is there a better solution?
- (set (make-local-variable 'coding-system-for-write) 'no-conversion)
(widen)
nil))
+;; Used to restore the encoding of the buffer where we show the
+;; current message, after we save the message collection. This is
+;; needed because rmail-write-region-annotate switches buffers behind
+;; save-file's back, with the side effect that last-coding-system-used
+;; is assigned to buffer-file-coding-system of the wrong buffer.
+(defun rmail-after-save-hook ()
+ (if (or (eq rmail-view-buffer (current-buffer))
+ (eq rmail-buffer (current-buffer)))
+ (with-current-buffer
+ (if (rmail-buffers-swapped-p) rmail-buffer rmail-view-buffer)
+ (setq buffer-file-coding-system rmail-message-encoding))))
+(add-hook 'after-save-hook 'rmail-after-save-hook)
+
;;; Start of automatically extracted autoloads.
This bug report was last modified 15 years and 165 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.