[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: ;;; sb-fau.el --- Freie ArbeiterInnen Union shimbun backend



Hi David,

>>>>> In [emacs-w3m : No.07938] David Hansen wrote:

> Description: FAU is a German anarcho-syndicalism labor union.

> ;;; sb-fau.el --- Freie ArbeiterInnen Union shimbun backend

Is it really practicable for people who read German?  I'm worried
those contents don't seem to be decoded correctly (I don't care
what they say since I don't read German, though).  For example,
the quotation marks `“' and `”' and the hyphen `–' seem to have
been encoded as \223, \224 and \226 respectively in the server.
I guess the fau.org server use the `windows-1252' coding system
even if it is not specified in the header information.  To solve
the problem, ARISAWA Akihiro proposed the following:

(defvar shimbun-fau-coding-system
  (or (shimbun-find-coding-system 'windows-1252)
      (shimbun-find-coding-system 'latin-iso8859-1)))

;; It should be put into shimbun.el.
(defalias 'shimbun-find-coding-system 'w3m-find-coding-system)

The value of `shimbun-fau-coding-system' is passed to
`detect-coding-with-priority' as the topmost of the priority
list by way of `w3m-decode-buffer'.  However, Emacs doesn't
always decode the contents correctly because Latin-1 is superior
to `windows-1252' there.  I think the best solution is to fetch
the raw contents and to decode them by itself.  The patch is
below.  Although it cannot help Emacsen in which `windows-1252'
is not supported, it is better than do nothing.  WDYT?

--- sb-fau.el~	2005-03-19 15:50:59 +0000
+++ sb-fau.el	2005-03-22 04:23:20 +0000
@@ -46,6 +46,14 @@
 <p>\\s-*
 ..*?<a\\s-+class=\"red\"\\s-+href=\"javascript:window.print()\"")
 
+;; It should be moved to shimbun.el.
+(defalias 'shimbun-find-coding-system 'w3m-find-coding-system)
+
+(defvar shimbun-fau-coding-system
+  (or (shimbun-find-coding-system 'windows-1252)
+      (shimbun-find-coding-system 'latin-iso8859-1))
+  "*Coding system used to decode article contents.")
+
 (luna-define-method shimbun-index-url ((shimbun shimbun-fau))
   shimbun-fau-url)
 
@@ -64,6 +72,27 @@
     (error "Cannot find message-id base"))
   (concat "<" (match-string 0 url) "@fau.de>"))
 
+(luna-define-method shimbun-article ((shimbun shimbun) header
+				     &optional outbuf)
+  (when (shimbun-current-group-internal shimbun)
+    (if shimbun-fau-coding-system
+	(with-current-buffer (or outbuf (current-buffer))
+	  (w3m-insert-string
+	   (or (with-temp-buffer
+		 (shimbun-fetch-url shimbun
+				    (shimbun-article-url shimbun header)
+				    nil t
+				    (shimbun-article-base-url shimbun header))
+		 (set-buffer-multibyte t)
+		 (decode-coding-region (point-min) (point-max)
+				       shimbun-fau-coding-system)
+		 (shimbun-message shimbun "shimbun: Make contents...")
+		 (goto-char (point-min))
+		 (prog1 (shimbun-make-contents shimbun header)
+		   (shimbun-message shimbun "shimbun: Make contents...done")))
+	       "")))
+      (luna-call-next-method))))
+
 (provide 'sb-fau)
 
 ;;; sb-fau.el ends here