[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [HELP] (bug?) Saving a buffer without any conversion?
From: |
Kim F. Storm |
Subject: |
Re: [HELP] (bug?) Saving a buffer without any conversion? |
Date: |
15 Jan 2003 14:27:23 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Kenichi Handa <address@hidden> writes:
> In article <address@hidden>, address@hidden (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 <address@hidden> http://www.cua.dk
- [HELP] (bug?) Saving a buffer without any conversion?, Mario Lang, 2003/01/13
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Kenichi Handa, 2003/01/14
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Kenichi Handa, 2003/01/15
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Richard Stallman, 2003/01/17
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Kenichi Handa, 2003/01/17
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Mario Lang, 2003/01/15
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Richard Stallman, 2003/01/15
- Re: [HELP] (bug?) Saving a buffer without any conversion?, Kenichi Handa, 2003/01/16