From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: [HELP] (bug?) Saving a buffer without any conversion? Date: 15 Jan 2003 14:27:23 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5xbs2i7dc4.fsf@kfs2.cua.dk> References: <87fzrxszs8.fsf@lexx.delysid.org> <200301150116.KAA09223@etlken.m17n.org> <5xk7h67k1b.fsf@kfs2.cua.dk> <200301151059.TAA09873@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1042633645 6117 80.91.224.249 (15 Jan 2003 12:27:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 15 Jan 2003 12:27:25 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18Ymdf-0001aX-00 for ; Wed, 15 Jan 2003 13:27:23 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18Ymm6-0002FT-00 for ; Wed, 15 Jan 2003 13:36:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Ymej-0005W0-04 for emacs-devel@quimby.gnus.org; Wed, 15 Jan 2003 07:28:29 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18YmeN-0005To-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 07:28:07 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18YmeJ-0005Rv-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 07:28:07 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18YmeI-0005Pd-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 07:28:02 -0500 Original-Received: from kfs2.cua.dk.cua.dk (kfs2.local.filanet.dk [192.168.1.182]) by mail.filanet.dk (Postfix) with SMTP id 74B1C7C018; Wed, 15 Jan 2003 13:27:58 +0100 (CET) Original-To: Kenichi Handa In-Reply-To: <200301151059.TAA09873@etlken.m17n.org> Original-Lines: 60 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-cc: mlang@delysid.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10748 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10748 Kenichi Handa writes: > In article <5xk7h67k1b.fsf@kfs2.cua.dk>, storm@cua.dk (Kim F. Storm) writes: > > He uses a process filter to "insert" the received strings to the > > buffer like this [approximately]: > > > (defun filter (proc string) > > (with-current-buffer (process-buffer proc) > > (insert string))) > > Ah! Now I see what's going on. If the coding system for > proc is no-conversion or raw-text, STRING above is unibyte, > thus, when inserted in a multibyte buffer, it is converted > to the corresponding multibyte string. This conversion > converts all 0xA0..0xFF to Latin-1 (in Latin-1 lang. env.). I see. Now I understand it too ... > Yes. And, instead of adding that, chaging this: > ... > to this: > > > :filter (lambda (proc string) > > (with-current-buffer (get-buffer "temp.out") > > (insert (string-as-multibyte string)))) > > also produces the right result. I think we need to write something about this somewhere. E.g. add this to the doc string for `set-process-filter': If the process' input coding system is no-conversion or raw-text, the string argument to the filter function is a unibyte string; otherwise it is a multibyte string. Use `string-as-multibyte' on a unibyte string before inserting it in a multibyte buffer. Note: If the sole purpose of the filter is to insert received data into a specific buffer, it is better NOT to define a process filter, but instead set the process' buffer to that buffer. > > Which is the better solution? It depends on how the buffer > is used later. If it is just to save the received bytes in > a file, using a unibyte buffer is better. But, in that > case, first of all, why is the process filter necessary? > I don't know ... I didn't write the code :-) In any case, I have just confirmed that if you DON'T use a filter function, but rather relies on emacs itself to insert received data into the buffer, it works nicely even with a multibyte buffer. -- Kim F. Storm http://www.cua.dk