* elmo.el: Moved obsolete variable definitions from
[elisp/wanderlust.git] / elmo / sb-airs.el
1 ;;; sb-airs.el --- shimbun backend for lists.airs.net
2
3 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
4
5 ;; Keywords: news
6
7 ;;; Copyright:
8
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program; if not, you can either send email to this
21 ;; program's maintainer or write to: The Free Software Foundation,
22 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;; Original was nnshimbun-airs.el on http://homepage2.nifty.com/strlcat/
27
28 ;;; Code:
29
30 (require 'shimbun)
31
32 (luna-define-class shimbun-airs (shimbun-mhonarc) ())
33
34 (defconst shimbun-airs-group-path-alist
35   '(("semi-gnus-ja" . "semi-gnus/archive")
36     ("wl" . "wl/archive")))
37
38 (defvar shimbun-airs-url "http://lists.airs.net/")
39 (defvar shimbun-airs-groups (mapcar 'car shimbun-airs-group-path-alist))
40 (defvar shimbun-airs-coding-system (static-if (boundp 'MULE)
41                                        '*euc-japan* 'euc-jp))
42
43 (defmacro shimbun-airs-concat-url (shimbun url)
44   (` (concat (shimbun-url-internal (, shimbun))
45              (cdr (assoc (shimbun-current-group-internal (, shimbun))
46                          shimbun-airs-group-path-alist))
47              "/"
48              (, url))))
49
50 (luna-define-method shimbun-index-url ((shimbun shimbun-airs))
51   (shimbun-airs-concat-url shimbun "index.html"))
52
53 (luna-define-method shimbun-get-headers ((shimbun shimbun-airs))
54   (let ((case-fold-search t) headers months)
55     (goto-char (point-min))
56     ;; Only first month...
57     (if (re-search-forward "<A HREF=\"\\([0-9]+\\)/\">" nil t)
58         (push (match-string 1) months))
59     (setq months (nreverse months))
60     (dolist (month months)
61       (erase-buffer)
62       (shimbun-retrieve-url
63        shimbun
64        (shimbun-airs-concat-url shimbun (concat month "/index.html"))
65        t)
66       (let (id url subject)
67         (goto-char (point-max))
68         (while (re-search-backward
69                 "<A[^>]*HREF=\"\\(msg\\([0-9]+\\)\\.html\\)\">\\([^<]+\\)</A>"
70                 nil t)
71           (setq url (shimbun-airs-concat-url
72                      shimbun
73                      (concat month "/" (match-string 1)))
74                 id (format "<%s%05d%%%s>"
75                            month
76                            (string-to-number (match-string 2))
77                            (shimbun-current-group-internal shimbun))
78                 subject (match-string 3))
79           (save-excursion
80             (goto-char (match-end 0))
81             (push (shimbun-make-header
82                    0
83                    (shimbun-mime-encode-string subject)
84                    (if (looking-at "</STRONG> *<EM>\\([^<]+\\)<")
85                        (shimbun-mime-encode-string (match-string 1))
86                      "")
87                    "" id "" 0 0 url)
88                   headers)))))
89     headers))
90
91 (provide 'sb-airs)