From: Katsumi Yamaoka <yamaoka@jpl.org>
Subject: Re: mm-with-unibyte-current-buffer is bad for Emacs 23
Date: Wed, 01 Mar 2006 08:47:47 +0900 [thread overview]
Message-ID: <b4m1wxn9hb0.fsf@jpl.org> (raw)
In-Reply-To: <v9r75nhaa5.fsf@marauder.physik.uni-ulm.de>
>>>>> In <v9r75nhaa5.fsf@marauder.physik.uni-ulm.de> 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-
next prev parent reply other threads:[~2006-02-28 23:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-28 9:48 Katsumi Yamaoka
2006-02-28 13:40 ` Reiner Steib
2006-02-28 23:47 ` Katsumi Yamaoka [this message]
2006-03-03 4:29 ` Katsumi Yamaoka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4m1wxn9hb0.fsf@jpl.org \
--to=yamaoka@jpl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).