Gnus development mailing list
 help / color / mirror / Atom feed
* Re: Why multibyte for original-article buffer
       [not found] <jwvd4qg3nfg.fsf-monnier+emacs@gnu.org>
@ 2008-02-29  0:35 ` Katsumi Yamaoka
  2008-02-29  4:22   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Katsumi Yamaoka @ 2008-02-29  0:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bugs, ding, emacs-devel

>>>>> Stefan Monnier wrote:

> I've been running with the following patch with good results.
> Also the patch makes sense to me: the original article is a sequence of
> bytes (i.e. encoded chars), so a unibyte buffer makes a lot of sense
> (it's more efficient and is likely to hide fewer bugs).

So, it is better to make also the " *nntpd*" buffer, the process
buffer for pop3, etc. be unibyte.  If such changes cause a problem,
it will be due to a code that copies data from those buffers to
a multibyte buffer and then decodes the data.  Actually, making
the original article buffer be unibyte prevents me from reading
a Japanese 8bit shift_jis message like this.

日本語

(Try `g' in the summary buffer.)

> Yet the code currently explicitly sets the buffer to multibyte mode.
> Does anybody know why?

IIRC, it was done about ten years ago.  I guess it was probably
a workaround for a problem like the one mentioned above.

> --- gnus-art.el.~1.154.~	2008-02-28 14:10:39.000000000 -0500
> +++ gnus-art.el	2008-02-28 14:09:51.000000000 -0500
> @@ -4342,7 +4342,7 @@
>      (gnus-article-setup-highlight-words)
>      ;; Init original article buffer.
>      (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
> -      (mm-enable-multibyte)
> +      (mm-disable-multibyte)
>        (setq major-mode 'gnus-original-article-mode)
>        (make-local-variable 'gnus-original-article))
>      (if (and (get-buffer name)

It is beyond my capacity to verify (and possibly to fix) all the
Gnus codes that copy data from there to somewhere.

Regards,




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why multibyte for original-article buffer
  2008-02-29  0:35 ` Why multibyte for original-article buffer Katsumi Yamaoka
@ 2008-02-29  4:22   ` Stefan Monnier
  2008-02-29  5:44     ` Katsumi Yamaoka
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-02-29  4:22 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: bugs, ding, emacs-devel

>> I've been running with the following patch with good results.
>> Also the patch makes sense to me: the original article is a sequence of
>> bytes (i.e. encoded chars), so a unibyte buffer makes a lot of sense
>> (it's more efficient and is likely to hide fewer bugs).

> So, it is better to make also the " *nntpd*" buffer, the process
> buffer for pop3, etc. be unibyte.  If such changes cause a problem,
> it will be due to a code that copies data from those buffers to
> a multibyte buffer and then decodes the data.  Actually, making
> the original article buffer be unibyte prevents me from reading
> a Japanese 8bit shift_jis message like this.

> 日本語

> (Try `g' in the summary buffer.)

Indeed, I see that.  The patch below will fix it.

>> Yet the code currently explicitly sets the buffer to multibyte mode.
>> Does anybody know why?

> IIRC, it was done about ten years ago.  I guess it was probably
> a workaround for a problem like the one mentioned above.

Yes, the Gnus code is full of such things.  I suggest it's time to take
a step back and think about how things *should* work.  Then change the
parts for which we know how they should work.  This will introduce bugs,
but then we'll know that the bugs are elsewhere and that fixing them
will get us closer to a good solution.


        Stefan


@@ -6564,7 +6564,13 @@
 		 (with-current-buffer gnus-original-article-buffer
 		   (and (equal (car gnus-original-article) group)
 			(eq (cdr gnus-original-article) article))))
-	    (insert-buffer-substring gnus-original-article-buffer)
+            ;; `insert-buffer-substring' would incorrectly use the
+            ;; equivalent of string-make-multibyte which amounts to decoding
+            ;; with locale-coding-system, causing failure of
+            ;; subsequent decoding.
+            (insert (mm-string-to-multibyte
+                     (with-current-buffer gnus-original-article-buffer
+                       (buffer-substring (point-min) (point-max)))))
 	    'article)
 	   ;; Check the backlog.
 	   ((and gnus-keep-backlog




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why multibyte for original-article buffer
  2008-02-29  4:22   ` Stefan Monnier
@ 2008-02-29  5:44     ` Katsumi Yamaoka
  2008-02-29  6:18       ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: Katsumi Yamaoka @ 2008-02-29  5:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bugs, ding, emacs-devel

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Indeed, I see that.  The patch below will fix it.

It works.

> -	    (insert-buffer-substring gnus-original-article-buffer)
> +            ;; `insert-buffer-substring' would incorrectly use the
> +            ;; equivalent of string-make-multibyte which amounts to decoding
> +            ;; with locale-coding-system, causing failure of
> +            ;; subsequent decoding.
> +            (insert (mm-string-to-multibyte
> +                     (with-current-buffer gnus-original-article-buffer
> +                       (buffer-substring (point-min) (point-max)))))

This might be the most suitable occasion to decode raw data into
the human readable ones rather than only converting the multibyteness.
It suggests there will also be such items lying about here and
there.  Though I think it should be done for the second step.

> Yes, the Gnus code is full of such things.  I suggest it's time to take
> a step back and think about how things *should* work.  Then change the
> parts for which we know how they should work.  This will introduce bugs,
> but then we'll know that the bugs are elsewhere and that fixing them
> will get us closer to a good solution.

Great.  I agree with installing those two changes as the first
step, though it might force non-ASCII people to live hard with
No Gnus for a while,   I will one by one fix or at least report
things caused by it.

Regards,




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why multibyte for original-article buffer
  2008-02-29  5:44     ` Katsumi Yamaoka
@ 2008-02-29  6:18       ` Miles Bader
  0 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2008-02-29  6:18 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: Stefan Monnier, bugs, ding, emacs-devel

Katsumi Yamaoka <yamaoka@jpl.org> writes:
> though it might force non-ASCII people to live hard with
> No Gnus for a while

That's their job... :-)

-Miles

-- 
Abstainer, n. A weak person who yields to the temptation of denying himself a
pleasure. A total abstainer is one who abstains from everything but
abstention, and especially from inactivity in the affairs of others.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-29  6:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <jwvd4qg3nfg.fsf-monnier+emacs@gnu.org>
2008-02-29  0:35 ` Why multibyte for original-article buffer Katsumi Yamaoka
2008-02-29  4:22   ` Stefan Monnier
2008-02-29  5:44     ` Katsumi Yamaoka
2008-02-29  6:18       ` Miles Bader

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).