unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: [HELP] (bug?) Saving a buffer without any conversion?
Date: 15 Jan 2003 14:27:23 +0100	[thread overview]
Message-ID: <5xbs2i7dc4.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <200301151059.TAA09873@etlken.m17n.org>

Kenichi Handa <handa@m17n.org> 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 <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2003-01-15 13:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-13 17:52 [HELP] (bug?) Saving a buffer without any conversion? Mario Lang
2003-01-14  1:00 ` Kim F. Storm
2003-01-14  6:06   ` Eli Zaretskii
2003-01-14  6:46     ` Mario Lang
2003-01-14 18:37       ` Eli Zaretskii
2003-01-14 16:19   ` Stefan Monnier
2003-01-15  1:16 ` Kenichi Handa
2003-01-15 11:02   ` Kim F. Storm
2003-01-15 10:59     ` Kenichi Handa
2003-01-15 13:27       ` Kim F. Storm [this message]
2003-01-15 16:30         ` Eli Zaretskii
2003-01-16 22:52           ` Kim F. Storm
2003-01-17  2:35             ` Kenichi Handa
2003-01-16  1:18         ` Kenichi Handa
2003-01-17  9:23         ` Richard Stallman
2003-01-17 11:07           ` Kenichi Handa
2003-01-15 16:59       ` Mario Lang
2003-01-15 23:27       ` Richard Stallman
2003-01-16  6:45         ` Kenichi Handa

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xbs2i7dc4.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).