From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/62106 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: mm-with-unibyte-current-buffer is bad for Emacs 23 Date: Wed, 01 Mar 2006 08:47:47 +0900 Organization: Emacsen advocacy group Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1141170821 30144 80.91.229.2 (28 Feb 2006 23:53:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 28 Feb 2006 23:53:41 +0000 (UTC) Original-X-From: ding-owner+m10634@lists.math.uh.edu Wed Mar 01 00:53:39 2006 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FEEeB-0001qI-SA for ding-account@gmane.org; Wed, 01 Mar 2006 00:52:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1FEEe7-0005CQ-00; Tue, 28 Feb 2006 17:52:47 -0600 Original-Received: from nas01.math.uh.edu ([129.7.128.39]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1FEEZP-0005CL-00 for ding@lists.math.uh.edu; Tue, 28 Feb 2006 17:47:55 -0600 Original-Received: from quimby.gnus.org ([80.91.224.244]) by nas01.math.uh.edu with esmtp (Exim 4.52) id 1FEEZN-0004ug-A5 for ding@lists.math.uh.edu; Tue, 28 Feb 2006 17:47:55 -0600 Original-Received: from washington.hostforweb.net ([66.225.201.13]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1FEEZM-0007Xx-00 for ; Wed, 01 Mar 2006 00:47:52 +0100 Original-Received: from [205.234.185.198] (port=45853 helo=mail.jpl.org) by washington.hostforweb.net with esmtpa (Exim 4.52) id 1FEEZK-0005Mk-N7 for ding@gnus.org; Tue, 28 Feb 2006 17:47:51 -0600 Original-To: ding@gnus.org X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:ZpdH+T8yZKV6rhmhtRSRACfPUhI= X-Hashcash: 1:20:060228:ding@gnus.org::vXNUcPt/A0bR+vcV:000007CS X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - washington.hostforweb.net X-AntiAbuse: Original Domain - gnus.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -2.5 (--) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:62106 Archived-At: >>>>> In Reiner Steib wrote: > On Tue, Feb 28 2006, Katsumi Yamaoka wrote: >> The macro `mm-with-unibyte-current-buffer' is used here and >> there in Gnus. In Emacs 23, I realized there is a possibility >> that it breaks non-ASCII text. > Unless you can fix it, please put a note into the code like... > ;; FIXME: ... Emacs 23 (unicode) If anything, we should not use '(set-buffer-multibyte t)' in unibyte buffers which aren't empty if there's no special purpose. For instance, the following code might work in a certain limited condition (it is for decoding encoded text and displaying it). (set-buffer-multibyte t) (decode-coding-region (point-min) (point-max) 'CODING-SYSTEM) But we need to change the order as follows for Emacs 23. (decode-coding-region (point-min) (point-max) 'CODING-SYSTEM) (set-buffer-multibyte t) However, it might become not working when the Emacs 23 spec will change in the future. I got a suggestion from Kenichi Handa yesterday. The best way to do such a thing is to manipulate data outside the buffer. For instance: (insert (prog1 (decode-coding-string (buffer-string) 'CODING-SYSTEM) (erase-buffer) (set-buffer-multibyte t))) I don't know very much how the macro is used in Gnus modules, and I don't have a capacity to examine all of them either. So, I've added the following note to the docstring. #v+ NOTE: Use this macro with caution in multibyte buffers (it is not worth using this macro in unibyte buffers of course). Use of `(set-buffer-multibyte t)', which is run finally, is generally harmful since it is likely to modify existing data in the buffer. For instance, it converts "\300\255" into "\255" in Emacs 23. #v-