From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: buffer-swap-text and multibyteness Date: Wed, 04 Feb 2009 23:26:12 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1233808007 16902 80.91.229.12 (5 Feb 2009 04:26:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Feb 2009 04:26:47 +0000 (UTC) Cc: eliz@gnu.org, rms@gnu.org, emacs-devel@gnu.org To: Kenichi Handa Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 05 05:28:01 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LUvqK-0006Zd-O5 for ged-emacs-devel@m.gmane.org; Thu, 05 Feb 2009 05:28:01 +0100 Original-Received: from localhost ([127.0.0.1]:55491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUvp1-0003ro-IP for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2009 23:26:39 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUvow-0003o9-3T for emacs-devel@gnu.org; Wed, 04 Feb 2009 23:26:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUvov-0003n8-FZ for emacs-devel@gnu.org; Wed, 04 Feb 2009 23:26:33 -0500 Original-Received: from [199.232.76.173] (port=47268 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUvov-0003ms-AN for emacs-devel@gnu.org; Wed, 04 Feb 2009 23:26:33 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:65377) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUvor-000848-9D; Wed, 04 Feb 2009 23:26:29 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIEANr5iUlFxIvi/2dsb2JhbACBbs4zhBYGgwI X-IronPort-AV: E=Sophos;i="4.37,382,1231131600"; d="scan'208";a="33353540" Original-Received: from 69-196-139-226.dsl.teksavvy.com (HELO ceviche.home) ([69.196.139.226]) by ironport2-out.teksavvy.com with ESMTP; 04 Feb 2009 23:26:12 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 77C71B400C; Wed, 4 Feb 2009 23:26:12 -0500 (EST) In-Reply-To: (Kenichi Handa's message of "Mon, 02 Feb 2009 11:48:00 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108770 Archived-At: > It always fails. For instance, this mail contains signle > A-grave here: > =C0 > Please edit this message after typing e > (rmail-edit-current-message) and type C-c C-c. The above > line is changed to \300 (byte #xC0). Have you tried the patch I sent (and which I re-appended below)? Stefan - narrow should take place before extracting the headers. - insert-buffer-substring from a multibyte buffer to a unibyte buffer (as here), has tricky semantics. Better do the encoding at that point, so we're going from multibyte non-encoded text to unibyte encoded text, both of which are well understood. - text encoding should take place before the QP/base64 encoding. Index: lisp/mail/rmailedit.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/mail/rmailedit.el,v retrieving revision 1.47 diff -u -r1.47 rmailedit.el --- lisp/mail/rmailedit.el 1 Feb 2009 03:26:20 -0000 1.47 +++ lisp/mail/rmailedit.el 2 Feb 2009 01:23:45 -0000 @@ -143,7 +143,10 @@ (search-forward "\n\n") (setq headers-end (point)) =20 (rmail-swap-buffers-maybe) + + (narrow-to-region (rmail-msgbeg rmail-current-message) + (rmail-msgend rmail-current-message)) =20 (setq character-coding (mail-fetch-field "content-transfer-encoding") is-text-message (rmail-is-text-p) @@ -151,28 +154,25 @@ (if character-coding (setq character-coding (downcase character-coding))) =20 - (narrow-to-region (rmail-msgbeg rmail-current-message) - (rmail-msgend rmail-current-message)) (goto-char (point-min)) (search-forward "\n\n") - (let ((inhibit-read-only t) - (headers-end-1 (point))) - (insert-buffer-substring rmail-view-buffer headers-end) - (delete-region (point) (point-max)) + (let ((inhibit-read-only t)) + (let ((data-buffer (current-buffer)) + (end (copy-marker (point) t))) + (with-current-buffer rmail-view-buffer + (encode-coding-region headers-end (point-max) coding-system + data-buffer)) + (delete-region end (point-max))) =20 ;; Re-encode the message body in whatever ;; way it was decoded. (cond ((string=3D character-coding "quoted-printable") - (mail-quote-printable-region headers-end-1 (point-max))) + (mail-quote-printable-region (point) (point-max))) ((and (string=3D character-coding "base64") is-text-message) - (base64-encode-region headers-end-1 (point-max))) + (base64-encode-region (point) (point-max))) ((eq character-coding 'uuencode) - (error "Not supported yet.")) - (t - (if (or (not coding-system) (not (coding-system-p coding-system))) - (setq coding-system 'undecided)) - (encode-coding-region headers-end-1 (point-max) coding-system))) + (error "Not supported yet."))) )) =20 (rmail-set-attribute rmail-edited-attr-index t)