From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#4623: 23.1.50; rmail changes encoding of characters on save Date: Sat, 05 Dec 2009 14:03:29 +0200 Message-ID: <83hbs5k4q6.fsf@gnu.org> References: <831vjalmrl.fsf@gnu.org> <83y6lik0ug.fsf@gnu.org> Reply-To: Eli Zaretskii , 4623@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1260016072 18394 80.91.229.12 (5 Dec 2009 12:27:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Dec 2009 12:27:52 +0000 (UTC) Cc: 4623@emacsbugs.donarmstrong.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 05 13:27:45 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NGtjg-0005k5-IW for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Dec 2009 13:27:40 +0100 Original-Received: from localhost ([127.0.0.1]:50544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGtjg-0005nd-7O for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Dec 2009 07:27:40 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGtjb-0005my-Jw for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 07:27:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGtjV-0005kw-Fh for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 07:27:34 -0500 Original-Received: from [199.232.76.173] (port=59011 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGtjU-0005km-NM for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 07:27:28 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:36607) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NGtjU-00030x-5L for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 07:27:28 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB5CRP6p011999; Sat, 5 Dec 2009 04:27:25 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nB5CF3RR011065; Sat, 5 Dec 2009 04:15:03 -0800 Resent-Date: Sat, 5 Dec 2009 04:15:03 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Eli Zaretskii Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sat, 05 Dec 2009 12:15:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4623 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4623-submit@emacsbugs.donarmstrong.com id=B4623.126001474310615 (code B ref 4623); Sat, 05 Dec 2009 12:15:03 +0000 Original-Received: (at 4623) by emacsbugs.donarmstrong.com; 5 Dec 2009 12:05:43 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mtaout20.012.net.il (mtaout20.012.net.il [80.179.55.166]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB5C5flo010612 for <4623@emacsbugs.donarmstrong.com>; Sat, 5 Dec 2009 04:05:42 -0800 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0KU600100H3VLB00@a-mtaout20.012.net.il> for 4623@emacsbugs.donarmstrong.com; Sat, 05 Dec 2009 14:05:34 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([77.126.213.252]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0KU6000D3HL8B840@a-mtaout20.012.net.il>; Sat, 05 Dec 2009 14:05:33 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sat, 05 Dec 2009 07:27:33 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33248 Archived-At: > From: Stefan Monnier > 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)))