1 ;;; nnshimbun.el --- interfacing with web newspapers -*- coding: junet; -*-
3 ;; Authors: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>
4 ;; Akihiro Arisawa <ari@atesoft.advantest.co.jp>
9 ;; This file is a part of Semi-Gnus.
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
28 ;; Gnus backend to read newspapers on WEB.
33 (gnus-declare-backend "nnshimbun" 'address)
35 (eval-when-compile (require 'cl))
36 (eval-when-compile (require 'static))
42 (eval-when-compile (ignore-errors (require 'nnweb)))
43 ;; Report failure to find w3 at load time if appropriate.
44 (eval '(require 'nnweb))
48 (nnoo-declare nnshimbun)
50 (defvar nnshimbun-check-interval 300)
52 (defconst nnshimbun-mew-groups
53 '(("meadow-develop" "meadow-develop" nil t)
54 ("meadow-users-jp" "meadow-users-jp")
55 ("mule-win32" "mule-win32")
56 ("mew-win32" "mew-win32")
57 ("mew-dist" "mew-dist/3300" t)
58 ("mgp-users-jp" "mgp-users-jp/A" t t)))
60 (defvar nnshimbun-type-definition
62 (url . "http://spin.asahi.com/")
63 (groups "national" "business" "politics" "international" "sports" "personal" "feneral")
64 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
65 (generate-nov . nnshimbun-generate-nov-for-each-group)
66 (get-headers . nnshimbun-asahi-get-headers)
67 (index-url . (format "%sp%s.html" nnshimbun-url nnshimbun-current-group))
68 (from-address . "webmaster@www.asahi.com")
69 (make-contents . nnshimbun-make-text-or-html-contents)
70 (contents-start . "\n<!-- Start of kiji -->\n")
71 (contents-end . "\n<!-- End of kiji -->\n"))
73 (url . "http://www.sponichi.co.jp/")
74 (groups "baseball" "soccer" "usa" "others" "society" "entertainment" "horseracing")
75 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
76 (generate-nov . nnshimbun-generate-nov-for-each-group)
77 (get-headers . nnshimbun-sponichi-get-headers)
78 (index-url . (format "%s%s/index.html" nnshimbun-url nnshimbun-current-group))
79 (from-address . "webmaster@www.sponichi.co.jp")
80 (make-contents . nnshimbun-make-text-or-html-contents)
81 (contents-start . "\n<span class=\"text\">
\e$B!!
\e(B")
82 (contents-end . "\n"))
84 (url . "http://cnet.sphere.ne.jp/")
86 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
87 (generate-nov . nnshimbun-generate-nov-for-each-group)
88 (get-headers . nnshimbun-cnet-get-headers)
89 (index-url . (format "%s/News/Oneweek/" nnshimbun-url))
90 (from-address . "cnet@sphere.ad.jp")
91 (make-contents . nnshimbun-make-html-contents)
92 (contents-start . "\n<!--KIJI-->\n")
93 (contents-end . "\n<!--/KIJI-->\n"))
95 (url . "http://www.hotwired.co.jp/")
96 (groups "business" "culture" "technology")
97 (coding-system . ,(static-if (boundp 'MULE) '*euc-japan* 'euc-jp))
98 (generate-nov . nnshimbun-generate-nov-for-all-groups)
99 (get-headers . nnshimbun-wired-get-all-headers)
101 (from-address . "webmaster@www.hotwired.co.jp")
102 (make-contents . nnshimbun-make-html-contents)
103 (contents-start . "\n<!-- START_OF_BODY -->\n")
104 (contents-end . "\n<!-- END_OF_BODY -->\n"))
106 (url . "http://www.yomiuri.co.jp/")
107 (groups "shakai" "sports" "seiji" "keizai" "kokusai" "fuho")
108 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
109 (generate-nov . nnshimbun-generate-nov-for-all-groups)
110 (get-headers . nnshimbun-yomiuri-get-all-headers)
111 (index-url . (concat nnshimbun-url "main.htm"))
112 (from-address . "webmaster@www.yomiuri.co.jp")
113 (make-contents . nnshimbun-make-text-or-html-contents)
114 (contents-start . "\n<!-- honbun start -->\n")
115 (contents-end . "\n<!-- honbun end -->\n"))
117 (url . "http://www.zdnet.co.jp/news/")
119 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
120 (generate-nov . nnshimbun-generate-nov-for-each-group)
121 (get-headers . nnshimbun-zdnet-get-headers)
122 (index-url . nnshimbun-url)
123 (from-address . "zdnn@softbank.co.jp")
124 (make-contents . nnshimbun-make-html-contents)
125 (contents-start . "\\(<!--BODY-->\\|<!--DATE-->\\)")
126 (contents-end . "\\(<!--BODYEND-->\\|<!--BYLINEEND-->\\)"))
128 (url . "http://www.mew.org/archive/")
129 (groups ,@(mapcar #'car nnshimbun-mew-groups))
130 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
131 (generate-nov . nnshimbun-generate-nov-for-each-group)
132 (get-headers . nnshimbun-mew-get-headers)
133 (index-url . (nnshimbun-mew-concat-url "index.html"))
134 (make-contents . nnshimbun-make-mhonarc-contents))
136 (url . "http://list-archives.xemacs.org/")
137 (groups "xemacs-announce" "xemacs-beta-ja" "xemacs-beta"
138 "xemacs-build-reports" "xemacs-cvs" "xemacs-mule"
139 "xemacs-nt" "xemacs-patches" "xemacs-users-ja" "xemacs")
140 (coding-system . ,(static-if (boundp 'MULE) '*euc-japan* 'euc-jp))
141 (generate-nov . nnshimbun-generate-nov-for-each-group)
142 (get-headers . nnshimbun-xemacs-get-headers)
143 (index-url . (nnshimbun-xemacs-concat-url nil))
144 (make-contents . nnshimbun-make-mhonarc-contents))
146 (url . "http://www.jp.netbsd.org/ja/JP/ml/")
147 (groups "announce-ja" "junk-ja" "tech-misc-ja" "tech-pkg-ja"
148 "port-arm32-ja" "port-hpcmips-ja" "port-mac68k-ja"
149 "port-mips-ja" "port-powerpc-ja" "hpcmips-changes-ja"
150 "members-ja" "admin-ja" "www-changes-ja")
151 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
152 (generate-nov . nnshimbun-generate-nov-for-each-group)
153 (get-headers . nnshimbun-netbsd-get-headers)
154 (index-url . (format "%s%s/index.html" nnshimbun-url nnshimbun-current-group))
155 (make-contents . nnshimbun-make-mhonarc-contents))
157 (url . "http://www.rc.tutrp.tut.ac.jp/bbdb-ml/")
159 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
160 (generate-nov . nnshimbun-generate-nov-for-each-group)
161 (get-headers . nnshimbun-fml-get-headers)
162 (index-url . nnshimbun-url)
163 (make-contents . nnshimbun-make-fml-contents))
166 (defvar nnshimbun-x-face-alist
169 "X-Face: Ygq$6P.,%Xt$U)DS)cRY@k$VkW!7(X'X'?U{{osjjFG\"E]hND;SPJ-J?O?R|a?L
170 g2$0rVng=O3Lt}?~IId8Jj&vP^3*o=LKUyk(`t%0c!;t6REk=JbpsEn9MrN7gZ%"))))
171 "Alist of server vs. alist of group vs. X-Face field. It looks like:
173 \((\"asahi\" . ((\"national\" . \"X-face: ***\")
174 (\"business\" . \"X-Face: ***\")
177 (\"default\" . \"X-face: ***\")))
178 (\"sponichi\" . ((\"baseball\" . \"X-face: ***\")
179 (\"soccer\" . \"X-Face: ***\")
182 (\"default\" . \"X-face: ***\")))
184 (\"default\" . ((\"default\" . \"X-face: ***\")))")
186 (defvoo nnshimbun-directory (nnheader-concat gnus-directory "shimbun/")
187 "Where nnshimbun will save its files.")
189 (defvoo nnshimbun-nov-is-evil nil
190 "*Non-nil means that nnshimbun will never retrieve NOV headers.")
192 (defvoo nnshimbun-nov-file-name ".overview")
194 (defvoo nnshimbun-pre-fetch-article nil
195 "*Non nil means that nnshimbun fetch unread articles when scanning groups.")
197 ;; set by nnshimbun-possibly-change-group
198 (defvoo nnshimbun-buffer nil)
199 (defvoo nnshimbun-current-directory nil)
200 (defvoo nnshimbun-current-group nil)
202 ;; set by nnshimbun-open-server
203 (defvoo nnshimbun-url nil)
204 (defvoo nnshimbun-coding-system nil)
205 (defvoo nnshimbun-groups nil)
206 (defvoo nnshimbun-generate-nov nil)
207 (defvoo nnshimbun-get-headers nil)
208 (defvoo nnshimbun-index-url nil)
209 (defvoo nnshimbun-from-address nil)
210 (defvoo nnshimbun-make-contents nil)
211 (defvoo nnshimbun-contents-start nil)
212 (defvoo nnshimbun-contents-end nil)
213 (defvoo nnshimbun-server-directory nil)
215 (defvoo nnshimbun-status-string "")
216 (defvoo nnshimbun-nov-last-check nil)
217 (defvoo nnshimbun-nov-buffer-alist nil)
218 (defvoo nnshimbun-nov-buffer-file-name nil)
220 (defvoo nnshimbun-keep-backlog 300)
221 (defvoo nnshimbun-backlog-articles nil)
222 (defvoo nnshimbun-backlog-hashtb nil)
224 (defconst nnshimbun-meta-content-type-charset-regexp
226 (concat "<meta[ \t]+http-equiv=\"?Content-type\"?[ \t]+content=\"\\([^;]+\\)"
227 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
229 "Regexp used in parsing `<META HTTP-EQUIV=\"Content-Type\" content=\"...;charset=...\">
230 for a charset indication")
232 (defconst nnshimbun-meta-charset-content-type-regexp
234 (concat "<meta[ \t]+content=\"\\([^;]+\\)"
235 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
236 "[ \t]+http-equiv=\"?Content-type\"?>"))
237 "Regexp used in parsing `<META content=\"...;charset=...\" HTTP-EQUIV=\"Content-Type\">
238 for a charset indication")
243 (defmacro nnshimbun-backlog (&rest form)
244 `(let ((gnus-keep-backlog nnshimbun-keep-backlog)
245 (gnus-backlog-buffer (format " *nnshimbun backlog %s*" (nnoo-current-server 'nnshimbun)))
246 (gnus-backlog-articles nnshimbun-backlog-articles)
247 (gnus-backlog-hashtb nnshimbun-backlog-hashtb))
250 (setq nnshimbun-backlog-articles gnus-backlog-articles
251 nnshimbun-backlog-hashtb gnus-backlog-hashtb))))
252 (put 'nnshimbun-backlog 'lisp-indent-function 0)
253 (put 'nnshimbun-backlog 'edebug-form-spec '(form body))
257 ;;; Interface Functions
258 (nnoo-define-basics nnshimbun)
260 (deffoo nnshimbun-open-server (server &optional defs)
261 ;; Set default values.
262 (dolist (default (cdr (assoc server nnshimbun-type-definition)))
263 (let ((symbol (intern (concat "nnshimbun-" (symbol-name (car default))))))
264 (unless (assq symbol defs)
265 (push (list symbol (cdr default)) defs))))
266 ;; Set directory for server working files.
267 (push (list 'nnshimbun-server-directory
268 (file-name-as-directory
269 (expand-file-name server nnshimbun-directory)))
271 (nnoo-change-server 'nnshimbun server defs)
272 (nnshimbun-possibly-change-group nil server)
274 (unless (file-exists-p nnshimbun-directory)
275 (ignore-errors (make-directory nnshimbun-directory t)))
277 ((not (file-exists-p nnshimbun-directory))
278 (nnshimbun-close-server)
279 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-directory))
280 ((not (file-directory-p (file-truename nnshimbun-directory)))
281 (nnshimbun-close-server)
282 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-directory))
284 (unless (file-exists-p nnshimbun-server-directory)
285 (ignore-errors (make-directory nnshimbun-server-directory t)))
287 ((not (file-exists-p nnshimbun-server-directory))
288 (nnshimbun-close-server)
289 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-server-directory))
290 ((not (file-directory-p (file-truename nnshimbun-server-directory)))
291 (nnshimbun-close-server)
292 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-server-directory))
294 (nnheader-report 'nnshimbun "Opened server %s using directory %s"
295 server nnshimbun-server-directory)
298 (deffoo nnshimbun-close-server (&optional server)
299 (and (nnshimbun-server-opened server)
300 (gnus-buffer-live-p nnshimbun-buffer)
301 (kill-buffer nnshimbun-buffer))
302 (nnshimbun-backlog (gnus-backlog-shutdown))
304 (nnoo-close-server 'nnshimbun server)
307 (static-when (boundp 'MULE)
308 (unless (coding-system-p 'euc-japan)
309 (copy-coding-system '*euc-japan* 'euc-japan))
310 (unless (coding-system-p 'shift_jis)
311 (copy-coding-system '*sjis* 'shift_jis))
313 (defalias-maybe 'coding-system-category 'get-code-mnemonic)))
315 (defun nnshimbun-retrieve-url (url &optional no-cache)
316 "Rertrieve URL contents and insert to current buffer."
317 (let ((buf (current-buffer))
318 (url-working-buffer url-working-buffer))
319 (let ((old-asynch (default-value 'url-be-asynchronous))
320 (old-caching (default-value 'url-automatic-caching))
321 (old-mode (default-value 'url-standalone-mode)))
322 (setq-default url-be-asynchronous nil)
324 (setq-default url-automatic-caching nil)
325 (setq-default url-standalone-mode nil))
327 (let ((coding-system-for-read 'binary)
328 (coding-system-for-write 'binary)
329 (input-coding-system 'binary)
330 (output-coding-system 'binary)
331 (default-enable-multibyte-characters nil))
333 (setq url-working-buffer
334 (cdr (url-retrieve url no-cache))))
336 (setq-default url-be-asynchronous old-asynch)
337 (setq-default url-automatic-caching old-caching)
338 (setq-default url-standalone-mode old-mode)))
340 (or url-current-mime-charset
341 (let ((case-fold-search t))
342 (goto-char (point-min))
343 (if (or (re-search-forward
344 nnshimbun-meta-content-type-charset-regexp nil t)
346 nnshimbun-meta-charset-content-type-regexp nil t))
347 (buffer-substring-no-properties (match-beginning 2)
349 (decode-coding-region
350 (point-min) (point-max)
352 (let ((mime-charset-coding-system-alist
353 (append '((euc-jp . euc-japan)
354 (shift-jis . shift_jis)
355 (shift_jis . shift_jis)
357 (x-euc-jp . euc-japan)
358 (x-shift-jis . shift_jis)
359 (x-shift_jis . shift_jis)
360 (x-sjis . shift_jis))
361 mime-charset-coding-system-alist)))
362 (mime-charset-to-coding-system charset))
363 (let ((default (condition-case nil
364 (coding-system-category nnshimbun-coding-system)
366 (candidate (detect-coding-region (point-min) (point-max))))
367 (unless (listp candidate)
368 (setq candidate (list candidate)))
370 (dolist (coding candidate)
371 (if (eq default (coding-system-category coding))
372 (throw 'coding coding)))
373 (if (eq (coding-system-category 'binary)
374 (coding-system-category (car candidate)))
375 nnshimbun-coding-system
376 (car candidate)))))))
377 (set-buffer-multibyte t)
379 (insert-buffer url-working-buffer)
380 (kill-buffer url-working-buffer)))
382 (deffoo nnshimbun-request-article (article &optional group server to-buffer)
383 (when (nnshimbun-possibly-change-group group server)
384 (if (stringp article)
385 (setq article (nnshimbun-search-id group article)))
386 (if (integerp article)
387 (nnshimbun-request-article-1 article group server to-buffer)
388 (nnheader-report 'nnml "Couldn't retrieve article: %s" (prin1-to-string article))
391 (defsubst nnshimbun-header-xref (x)
392 (if (and (setq x (mail-header-xref x))
393 (string-match "^Xref: " x))
397 (defun nnshimbun-request-article-1 (article &optional group server to-buffer)
398 (if (nnshimbun-backlog
399 (gnus-backlog-request-article
400 group article (or to-buffer nntp-server-buffer)))
402 (let (header contents)
403 (when (setq header (save-excursion
404 (set-buffer (nnshimbun-open-nov group))
405 (and (nnheader-find-nov-line article)
406 (nnheader-parse-nov))))
407 (let* ((xref (nnshimbun-header-xref header))
408 (x-faces (cdr (or (assoc (or server
409 (nnoo-current-server 'nnshimbun))
410 nnshimbun-x-face-alist)
411 (assoc "default" nnshimbun-x-face-alist))))
412 (x-face (cdr (or (assoc group x-faces)
413 (assoc "default" x-faces)))))
415 (set-buffer nnshimbun-buffer)
417 (nnshimbun-retrieve-url xref)
418 (nnheader-message 6 "nnshimbun: Make contents...")
419 (goto-char (point-min))
420 (setq contents (funcall nnshimbun-make-contents header x-face))
421 (nnheader-message 6 "nnshimbun: Make contents...done"))))
424 (set-buffer (or to-buffer nntp-server-buffer))
428 (gnus-backlog-enter-article group article (current-buffer)))
429 (nnheader-report 'nnshimbun "Article %s retrieved" (mail-header-id header))
430 (cons group (mail-header-number header)))))))
432 (deffoo nnshimbun-request-group (group &optional server dont-check)
433 (let ((pathname-coding-system 'binary))
435 ((not (nnshimbun-possibly-change-group group server))
436 (nnheader-report 'nnshimbun "Invalid group (no such directory)"))
437 ((not (file-exists-p nnshimbun-current-directory))
438 (nnheader-report 'nnshimbun "Directory %s does not exist"
439 nnshimbun-current-directory))
440 ((not (file-directory-p nnshimbun-current-directory))
441 (nnheader-report 'nnshimbun "%s is not a directory" nnshimbun-current-directory))
443 (nnheader-report 'nnshimbun "Group %s selected" group)
448 (set-buffer (nnshimbun-open-nov group))
449 (goto-char (point-min))
450 (setq beg (ignore-errors (read (current-buffer))))
451 (goto-char (point-max))
453 (setq end (ignore-errors (read (current-buffer)))
454 lines (count-lines (point-min) (point-max))))
455 (nnheader-report 'nnshimbunw "Selected group %s" group)
456 (nnheader-insert "211 %d %d %d %s\n"
457 lines (or beg 0) (or end 0) group))))))
459 (deffoo nnshimbun-request-scan (&optional group server)
460 (nnshimbun-possibly-change-group group server)
461 (nnshimbun-generate-nov-database group))
463 (deffoo nnshimbun-close-group (group &optional server)
464 (nnshimbun-write-nov group)
467 (deffoo nnshimbun-request-list (&optional server)
469 (set-buffer nntp-server-buffer)
471 (dolist (group nnshimbun-groups)
472 (when (nnshimbun-possibly-change-group group server)
475 (set-buffer (nnshimbun-open-nov group))
476 (goto-char (point-min))
477 (setq beg (ignore-errors (read (current-buffer))))
478 (goto-char (point-max))
480 (setq end (ignore-errors (read (current-buffer)))))
481 (insert (format "%s %d %d n\n" group (or end 0) (or beg 0)))))))
485 (if (fboundp 'mime-entity-fetch-field)
487 (defun nnshimbun-insert-header (header)
488 (insert "Subject: " (or (mime-entity-fetch-field header 'Subject) "(none)") "\n"
489 "From: " (or (mime-entity-fetch-field header 'From) "(nobody)") "\n"
490 "Date: " (or (mail-header-date header) "") "\n"
491 "Message-ID: " (or (mail-header-id header) (nnmail-message-id)) "\n")
492 (let ((refs (mail-header-references header)))
495 (insert "References: " refs "\n")))
496 (insert "Lines: " (number-to-string (or (mail-header-lines header) 0)) "\n"
497 "Xref: " (nnshimbun-header-xref header) "\n"))
499 (defun nnshimbun-insert-header (header)
500 (nnheader-insert-header header)
502 (insert "Xref: " (nnshimbun-header-xref header) "\n"))))
504 (deffoo nnshimbun-retrieve-headers (articles &optional group server fetch-old)
505 (when (nnshimbun-possibly-change-group group server)
506 (if (nnshimbun-retrieve-headers-with-nov articles fetch-old)
509 (set-buffer nntp-server-buffer)
512 (dolist (art articles)
514 (setq art (nnshimbun-search-id group art)))
518 (set-buffer (nnshimbun-open-nov group))
519 (and (nnheader-find-nov-line art)
520 (nnheader-parse-nov))))
521 (insert (format "220 %d Article retrieved.\n" art))
522 (nnshimbun-insert-header header)
524 (delete-region (point) (point-max))))))
527 (defun nnshimbun-retrieve-headers-with-nov (articles &optional fetch-old)
528 (if (or gnus-nov-is-evil nnshimbun-nov-is-evil)
530 (let ((nov (expand-file-name nnshimbun-nov-file-name nnshimbun-current-directory)))
531 (when (file-exists-p nov)
533 (set-buffer nntp-server-buffer)
535 (nnheader-insert-file-contents nov)
536 (if (and fetch-old (not (numberp fetch-old)))
537 t ; Don't remove anything.
538 (nnheader-nov-delete-outside-range
539 (if fetch-old (max 1 (- (car articles) fetch-old))
541 (car (last articles)))
546 ;;; Nov Database Operations
548 (defun nnshimbun-generate-nov-database (group)
549 (prog1 (funcall nnshimbun-generate-nov group)
550 (nnshimbun-write-nov group)))
552 (defun nnshimbun-generate-nov-for-each-group (group)
553 (nnshimbun-possibly-change-group group)
555 (set-buffer (nnshimbun-open-nov group))
557 (goto-char (point-max))
559 (setq i (or (ignore-errors (read (current-buffer))) 0))
560 (dolist (header (save-excursion
561 (set-buffer nnshimbun-buffer)
563 (nnshimbun-retrieve-url (eval nnshimbun-index-url) t)
564 (goto-char (point-min))
565 (funcall nnshimbun-get-headers)))
566 (unless (nnshimbun-search-id group (mail-header-id header))
567 (mail-header-set-number header (setq i (1+ i)))
568 (goto-char (point-max))
569 (nnheader-insert-nov header)
570 (if nnshimbun-pre-fetch-article
571 (nnshimbun-request-article-1 i group nil nnshimbun-buffer)))))))
573 (defun nnshimbun-generate-nov-for-all-groups (&rest args)
574 (unless (and nnshimbun-nov-last-check
575 (< (nnshimbun-lapse-seconds nnshimbun-nov-last-check)
576 nnshimbun-check-interval))
578 (dolist (list (funcall nnshimbun-get-headers))
579 (let ((group (car list)))
580 (nnshimbun-possibly-change-group group)
582 (set-buffer (nnshimbun-open-nov group))
584 (goto-char (point-max))
586 (setq i (or (ignore-errors (read (current-buffer))) 0))
587 (dolist (header (cdr list))
588 (unless (nnshimbun-search-id group (mail-header-id header))
589 (mail-header-set-number header (setq i (1+ i)))
590 (goto-char (point-max))
591 (nnheader-insert-nov header)
592 (if nnshimbun-pre-fetch-article
593 (nnshimbun-request-article-1 i group nil nnshimbun-buffer))))))))
595 (setq nnshimbun-nov-last-check (current-time)))))
597 (defun nnshimbun-search-id (group id &optional nov)
599 (set-buffer (nnshimbun-open-nov group))
600 (goto-char (point-min))
602 (while (and (not found)
603 (search-forward id nil t)) ; We find the ID.
604 ;; And the id is in the fourth field.
605 (if (not (and (search-backward "\t" nil t 4)
606 (not (search-backward "\t" (gnus-point-at-bol) t))))
611 (goto-char (point-min))
612 (when (search-forward (concat "X-Nnshimbun-Id: " id) nil t)
618 ;; We return the article number.
619 (ignore-errors (read (current-buffer))))))))
621 (defun nnshimbun-nov-fix-header (group header args)
623 (set-buffer (nnshimbun-open-nov group))
624 (when (nnheader-find-nov-line (mail-header-number header))
626 (if (eq (car arg) 'id)
627 (let ((extra (mail-header-extra header)))
628 (unless (assq 'X-Nnshimbun-Id extra)
629 (mail-header-set-extra
631 (cons (cons 'X-Nnshimbun-Id (mail-header-id header))
633 (mail-header-set-id header (cdr arg)))
634 (let ((func (intern (concat "mail-header-set-" (symbol-name (car arg))))))
635 (if (cdr arg) (eval (list func header (cdr arg)))))))
636 (mail-header-set-xref header (nnshimbun-header-xref header))
637 (delete-region (point) (progn (forward-line 1) (point)))
638 (nnheader-insert-nov header))))
640 (defun nnshimbun-open-nov (group)
641 (let ((buffer (cdr (assoc group nnshimbun-nov-buffer-alist))))
642 (if (buffer-live-p buffer)
644 (setq buffer (gnus-get-buffer-create
645 (format " *nnshimbun overview %s %s*"
646 (nnoo-current-server 'nnshimbun) group)))
649 (set (make-local-variable 'nnshimbun-nov-buffer-file-name)
651 nnshimbun-nov-file-name
652 (nnmail-group-pathname group nnshimbun-server-directory)))
654 (when (file-exists-p nnshimbun-nov-buffer-file-name)
655 (nnheader-insert-file-contents nnshimbun-nov-buffer-file-name))
656 (set-buffer-modified-p nil))
657 (push (cons group buffer) nnshimbun-nov-buffer-alist)
660 (defun nnshimbun-write-nov (group)
661 (let ((buffer (cdr (assoc group nnshimbun-nov-buffer-alist))))
662 (when (buffer-live-p buffer)
666 (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
669 (defun nnshimbun-save-nov ()
671 (while nnshimbun-nov-buffer-alist
672 (when (buffer-name (cdar nnshimbun-nov-buffer-alist))
673 (set-buffer (cdar nnshimbun-nov-buffer-alist))
674 (when (buffer-modified-p)
675 (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
677 (set-buffer-modified-p nil)
678 (kill-buffer (current-buffer)))
679 (setq nnshimbun-nov-buffer-alist (cdr nnshimbun-nov-buffer-alist)))))
683 ;;; Server Initialize
684 (defun nnshimbun-possibly-change-group (group &optional server)
686 (unless (nnshimbun-server-opened server)
687 (nnshimbun-open-server server)))
688 (unless (gnus-buffer-live-p nnshimbun-buffer)
689 (setq nnshimbun-buffer
691 (nnheader-set-temp-buffer
692 (format " *nnshimbun %s*" (nnoo-current-server 'nnshimbun))))))
695 (let ((pathname (nnmail-group-pathname group nnshimbun-server-directory))
696 (pathname-coding-system 'binary))
697 (unless (equal pathname nnshimbun-current-directory)
698 (setq nnshimbun-current-directory pathname
699 nnshimbun-current-group group))
700 (unless (file-exists-p nnshimbun-current-directory)
701 (ignore-errors (make-directory nnshimbun-current-directory t)))
703 ((not (file-exists-p nnshimbun-current-directory))
704 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-current-directory))
705 ((not (file-directory-p (file-truename nnshimbun-current-directory)))
706 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-current-directory))
714 (if (fboundp 'eword-encode-string)
716 (defun nnshimbun-mime-encode-string (string)
719 (split-string (eword-encode-string (nnweb-decode-entities-string string)) "\n")
722 (defun nnshimbun-mime-encode-string (string)
727 (insert (nnweb-decode-entities-string string))
728 (rfc2047-encode-region (point-min) (point-max))
729 (buffer-substring (point-min) (point-max)))
733 (defun nnshimbun-lapse-seconds (time)
734 (let ((now (current-time)))
735 (+ (* (- (car now) (car time)) 65536)
736 (- (nth 1 now) (nth 1 time)))))
738 (defun nnshimbun-make-date-string (year month day &optional time)
739 (format "%02d %s %04d %s +0900"
741 (aref [nil "Jan" "Feb" "Mar" "Apr" "May" "Jun"
742 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"]
748 ((< year 1000) ; possible 3-digit years.
753 (if (fboundp 'regexp-opt)
754 (defalias 'nnshimbun-regexp-opt 'regexp-opt)
755 (defun nnshimbun-regexp-opt (strings &optional paren)
756 "Return a regexp to match a string in STRINGS.
757 Each string should be unique in STRINGS and should not contain any regexps,
758 quoted or not. If optional PAREN is non-nil, ensure that the returned regexp
759 is enclosed by at least one regexp grouping construct."
760 (let ((open-paren (if paren "\\(" "")) (close-paren (if paren "\\)" "")))
761 (concat open-paren (mapconcat 'regexp-quote strings "\\|") close-paren))))
764 ;; Fast fill-region function
766 (defvar nnshimbun-fill-column (min 80 (- (frame-width) 4)))
768 (defconst nnshimbun-kinsoku-bol-list
770 (if (fboundp 'string-to-char-list)
773 !)-_~}]:;',.?
\e$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>!?!@!A
\e(B\
774 \e$B!B!C!D!E!G!I!K!M!O!Q!S!U!W!Y![!k!l!m!n$!$#$%$'$)$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v
\e(B"))
776 (defconst nnshimbun-kinsoku-eol-list
778 (if (fboundp 'string-to-char-list)
781 "({[`
\e$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!x
\e(B"))
783 (defun nnshimbun-fill-line ()
785 (let ((top (point)) chr)
786 (while (if (>= (move-to-column nnshimbun-fill-column)
787 nnshimbun-fill-column)
789 (if (memq (preceding-char) nnshimbun-kinsoku-eol-list)
792 (while (memq (preceding-char) nnshimbun-kinsoku-eol-list)
795 (while (memq (setq chr (following-char)) nnshimbun-kinsoku-bol-list)
797 (if (looking-at "\\s-+")
798 (or (eolp) (delete-region (point) (match-end 0)))
799 (or (> (char-width chr) 1)
800 (re-search-backward "\\<" top t)
802 (or (eolp) (insert "\n"))))))
807 (defsubst nnshimbun-shallow-rendering ()
808 (goto-char (point-min))
809 (while (search-forward "<p>" nil t)
811 (goto-char (point-min))
812 (while (search-forward "<br>" nil t)
814 (nnweb-remove-markup)
815 (nnweb-decode-entities)
816 (goto-char (point-min))
817 (while (nnshimbun-fill-line))
818 (goto-char (point-min))
819 (when (skip-chars-forward "\n")
820 (delete-region (point-min) (point)))
821 (while (search-forward "\n\n" nil t)
823 (when (skip-chars-forward "\n")
824 (delete-region p (point)))))
825 (goto-char (point-max))
826 (when (skip-chars-backward "\n")
827 (delete-region (point) (point-max)))
830 (defun nnshimbun-make-text-or-html-contents (header &optional x-face)
831 (let ((case-fold-search t) (html t) (start))
832 (when (and (re-search-forward nnshimbun-contents-start nil t)
834 (re-search-forward nnshimbun-contents-end nil t))
835 (delete-region (match-beginning 0) (point-max))
836 (delete-region (point-min) start)
837 (nnshimbun-shallow-rendering)
839 (goto-char (point-min))
840 (nnshimbun-insert-header header)
841 (insert "Content-Type: " (if html "text/html" "text/plain")
842 "; charset=ISO-2022-JP\nMIME-Version: 1.0\n")
848 (encode-coding-string (buffer-string)
849 (mime-charset-to-coding-system "ISO-2022-JP"))))
851 (defun nnshimbun-make-html-contents (header &optional x-face)
853 (when (and (re-search-forward nnshimbun-contents-start nil t)
855 (re-search-forward nnshimbun-contents-end nil t))
856 (delete-region (match-beginning 0) (point-max))
857 (delete-region (point-min) start))
858 (goto-char (point-min))
859 (nnshimbun-insert-header header)
860 (insert "Content-Type: text/html; charset=ISO-2022-JP\n"
861 "MIME-Version: 1.0\n")
867 (encode-coding-string (buffer-string)
868 (mime-charset-to-coding-system "ISO-2022-JP"))))
870 (defun nnshimbun-make-mhonarc-contents (header &rest args)
872 (if (search-forward "<!--X-Head-End-->" nil t)
875 ;; Processing headers.
877 (narrow-to-region (point-min) (point))
878 (nnweb-decode-entities)
879 (goto-char (point-min))
880 (while (search-forward "\n<!--X-" nil t)
881 (replace-match "\n"))
882 (goto-char (point-min))
883 (while (search-forward " -->\n" nil t)
884 (replace-match "\n"))
885 (goto-char (point-min))
886 (while (search-forward "\t" nil t)
888 (goto-char (point-min))
893 (delete-region (point) (progn (forward-line 1) (point))))
894 ((looking-at "Subject: +")
895 (push (cons 'subject (nnheader-header-value)) buf)
896 (delete-region (point) (progn (forward-line 1) (point))))
897 ((looking-at "From: +")
898 (push (cons 'from (nnheader-header-value)) buf)
899 (delete-region (point) (progn (forward-line 1) (point))))
900 ((looking-at "Date: +")
901 (push (cons 'date (nnheader-header-value)) buf)
902 (delete-region (point) (progn (forward-line 1) (point))))
903 ((looking-at "Message-Id: +")
904 (push (cons 'id (concat "<" (nnheader-header-value) ">")) buf)
905 (delete-region (point) (progn (forward-line 1) (point))))
906 ((looking-at "Reference: +")
907 (push (concat "<" (nnheader-header-value) ">") refs)
908 (delete-region (point) (progn (forward-line 1) (point))))
909 ((looking-at "Content-Type: ")
910 (unless (search-forward "charset" (gnus-point-at-eol) t)
912 (insert "; charset=ISO-2022-JP"))
914 (t (forward-line 1))))
915 (insert "MIME-Version: 1.0\n")
916 (if refs (push (cons 'references (mapconcat 'identity refs " ")) buf))
917 (nnshimbun-nov-fix-header nnshimbun-current-group header buf)
918 (goto-char (point-min))
919 (nnshimbun-insert-header header))
920 (goto-char (point-max)))
923 (narrow-to-region (point) (point-max))
927 (search-forward "\n<!--X-Body-of-Message-->\n" nil t)
929 (when (search-forward "\n<!--X-Body-of-Message-End-->\n" nil t)
931 (delete-region (point) (point-max)))
932 (nnweb-remove-markup)
933 (nnweb-decode-entities)))
934 (goto-char (point-min))
935 (nnshimbun-insert-header header)
936 (insert "Content-Type: text/html; charset=ISO-2022-JP\nMIME-Version: 1.0\n\n"))
937 (encode-coding-string (buffer-string)
938 (mime-charset-to-coding-system "ISO-2022-JP")))
940 (defun nnshimbun-make-fml-contents (header &rest args)
943 (if (search-forward "<SPAN CLASS=mailheaders>" nil t)
944 (delete-region (point-min) (point))
946 (if (search-forward "</PRE>")
949 (delete-region (point) (point-max)))
951 (if (search-backward "</SPAN>")
957 (narrow-to-region (point-min) (point))
958 (subst-char-in-region (point-min) (point-max) ?\t ? t)
959 (nnweb-decode-entities)
960 (goto-char (point-min))
961 (let (buf field value start value-beg end)
962 (while (and (setq start (point))
963 (re-search-forward "<SPAN CLASS=\\(.*\\)>\\(.*\\)</SPAN>:"
965 (setq field (match-string 2))
967 (concat "<SPAN CLASS=" (match-string 1) "-value>") nil t)
968 (setq value-beg (point))
969 (search-forward "</SPAN>" nil t)
971 (setq value (buffer-substring value-beg
972 (progn (search-backward "</SPAN>")
974 (delete-region start end)
975 (cond ((string= field "Date")
976 (push (cons 'date value) buf))
977 ((string= field "From")
978 (push (cons 'from value) buf))
979 ((string= field "Subject")
980 (push (cons 'subject value) buf))
981 ((string= field "Message-Id")
982 (push (cons 'id value) buf))
983 ((string= field "References")
984 (push (cons 'references value) buf))
986 (insert (concat field ": " value "\n")))))
987 (nnshimbun-nov-fix-header nnshimbun-current-group header buf)
988 (goto-char (point-min))
989 (nnshimbun-insert-header header))
990 (goto-char (point-max)))
993 (narrow-to-region (point) (point-max))
994 (nnweb-remove-markup)
995 (nnweb-decode-entities)))
996 (encode-coding-string (buffer-string)
997 (mime-charset-to-coding-system "ISO-2022-JP")))
1001 (defun nnshimbun-asahi-get-headers ()
1002 (when (search-forward "\n<!-- Start of past -->\n" nil t)
1003 (delete-region (point-min) (point))
1004 (when (search-forward "\n<!-- End of past -->\n" nil t)
1006 (delete-region (point) (point-max))
1007 (goto-char (point-min))
1009 (while (re-search-forward
1010 "^
\e$B"#
\e(B<a href=\"\\(\\([0-9][0-9][0-9][0-9]\\)/past/\\([A-z]*[0-9]*\\)\\.html\\)\"> *"
1012 (let ((id (format "<%s%s%%%s>"
1015 nnshimbun-current-group))
1016 (url (match-string 1)))
1017 (push (make-full-mail-header
1019 (nnshimbun-mime-encode-string
1020 (mapconcat 'identity
1024 (progn (search-forward "<br>" nil t) (point)))
1025 "\\(<[^>]+>\\|\r\\)")
1027 nnshimbun-from-address
1028 "" id "" 0 0 (concat nnshimbun-url url))
1030 (setq headers (nreverse headers))
1032 (while (and (nth i headers)
1034 "^\\[\\([0-9][0-9]\\)/\\([0-9][0-9]\\) \\([0-9][0-9]:[0-9][0-9]\\)\\]"
1036 (let ((month (string-to-number (match-string 1)))
1037 (date (decode-time (current-time))))
1038 (mail-header-set-date
1040 (nnshimbun-make-date-string
1041 (if (and (eq 12 month) (eq 1 (nth 4 date)))
1045 (string-to-number (match-string 2))
1048 (nreverse headers)))))
1052 ;;; www.sponichi.co.jp
1054 (defun nnshimbun-sponichi-get-headers ()
1055 (when (search-forward "
\e$B%K%e!<%9%$%s%G%C%/%9
\e(B" nil t)
1056 (delete-region (point-min) (point))
1057 (when (search-forward "
\e$B%"%I%?%0
\e(B" nil t)
1059 (delete-region (point) (point-max))
1060 (goto-char (point-min))
1061 (let ((case-fold-search t) headers)
1062 (while (re-search-forward
1063 "^<a href=\"/\\(\\([A-z]*\\)/kiji/\\([0-9][0-9][0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([0-9][0-9]\\)\\.html\\)\">"
1065 (let ((url (match-string 1))
1066 (id (format "<%s%s%s%s%%%s>"
1071 nnshimbun-current-group))
1072 (date (nnshimbun-make-date-string
1073 (string-to-number (match-string 3))
1074 (string-to-number (match-string 4))
1075 (string-to-number (match-string 5)))))
1076 (push (make-full-mail-header
1078 (nnshimbun-mime-encode-string
1079 (mapconcat 'identity
1083 (progn (search-forward "<br>" nil t) (point)))
1086 nnshimbun-from-address
1087 date id "" 0 0 (concat nnshimbun-url url))
1095 (defun nnshimbun-cnet-get-headers ()
1096 (let ((case-fold-search t) headers)
1097 (while (search-forward "\n<!--*****
\e$B8+=P$7
\e(B*****-->\n" nil t)
1098 (let ((subject (buffer-substring (point) (gnus-point-at-eol)))
1101 (when (looking-at "<a href=\"/\\(News/\\([0-9][0-9][0-9][0-9]\\)/Item/\\([0-9][0-9]\\([0-9][0-9]\\)\\([0-9][0-9]\\)-[0-9]+\\).html\\)\">")
1102 (let ((url (match-string 1))
1103 (id (format "<%s%s%%%s>"
1106 nnshimbun-current-group))
1107 (date (nnshimbun-make-date-string
1108 (string-to-number (match-string 2))
1109 (string-to-number (match-string 4))
1110 (string-to-number (match-string 5)))))
1111 (push (make-full-mail-header
1113 (nnshimbun-mime-encode-string subject)
1114 nnshimbun-from-address
1115 date id "" 0 0 (concat nnshimbun-url url))
1124 (defun nnshimbun-wired-get-all-headers ()
1126 (set-buffer nnshimbun-buffer)
1127 (let ((group-header-alist (mapcar (lambda (g) (cons g nil)) nnshimbun-groups))
1128 (case-fold-search t)
1130 "<a href=\"\\(%s\\|/\\)\\(news/news/\\(%s\\)/story/\\(\\([0-9][0-9][0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)[0-9]+\\)\\.html\\)\"><b>"
1131 (regexp-quote nnshimbun-url)
1132 (nnshimbun-regexp-opt nnshimbun-groups))))
1133 (dolist (xover (list (concat nnshimbun-url "news/news/index.html")
1134 (concat nnshimbun-url "news/news/last_seven.html")))
1136 (nnshimbun-retrieve-url xover t)
1137 (goto-char (point-min))
1138 (while (re-search-forward regexp nil t)
1139 (let* ((url (concat nnshimbun-url (match-string 2)))
1140 (group (downcase (match-string 3)))
1141 (id (format "<%s%%%s>" (match-string 4) group))
1142 (date (nnshimbun-make-date-string
1143 (string-to-number (match-string 5))
1144 (string-to-number (match-string 6))
1145 (string-to-number (match-string 7))))
1146 (header (make-full-mail-header
1148 (nnshimbun-mime-encode-string
1149 (mapconcat 'identity
1153 (progn (search-forward "</b>" nil t) (point)))
1156 nnshimbun-from-address
1157 date id "" 0 0 url))
1158 (x (assoc group group-header-alist)))
1159 (setcdr x (cons header (cdr x))))))
1160 group-header-alist)))
1164 ;;; www.yomiuri.co.jp
1166 (defun nnshimbun-yomiuri-get-all-headers ()
1168 (set-buffer nnshimbun-buffer)
1170 (nnshimbun-retrieve-url (eval nnshimbun-index-url) t)
1171 (let ((case-fold-search t)
1172 (group-header-alist (mapcar (lambda (g) (cons g nil)) nnshimbun-groups)))
1173 (dolist (group nnshimbun-groups)
1175 (goto-char (point-min))
1176 (when (and (search-forward (format "\n<!-- /news/%s=start -->\n" group) nil t)
1177 (setq start (point))
1178 (search-forward (format "\n<!-- /news/%s=end -->\n" group) nil t))
1181 (narrow-to-region start (point))
1183 (while (re-search-forward
1184 "<a href=\"/\\([0-9]+\\)/\\(\\(\\([0-9][0-9][0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)[A-z0-9]+\\)\\.htm\\)\"[^>]*>"
1186 (let ((url (concat (match-string 1) "a/" (match-string 2)))
1187 (id (format "<%s%s%%%s>"
1191 (year (string-to-number (match-string 4)))
1192 (month (string-to-number (match-string 5)))
1193 (day (string-to-number (match-string 6)))
1199 (progn (search-forward "<br>" nil t) (point)))
1203 (when (string-match "^
\e$B"!
\e(B" subject)
1204 (setq subject (substring subject (match-end 0))))
1205 (if (string-match "(\\([0-9][0-9]:[0-9][0-9]\\))$" subject)
1206 (setq date (nnshimbun-make-date-string
1207 year month day (match-string 1 subject))
1208 subject (substring subject 0 (match-beginning 0)))
1209 (setq date (nnshimbun-make-date-string year month day)))
1210 (setcdr (setq x (assoc group group-header-alist))
1211 (cons (make-full-mail-header
1213 (nnshimbun-mime-encode-string subject)
1214 nnshimbun-from-address
1215 date id "" 0 0 (concat nnshimbun-url url))
1217 group-header-alist)))
1223 (defun nnshimbun-zdnet-get-headers ()
1224 (let ((case-fold-search t) headers)
1225 (goto-char (point-min))
1227 (while (and (search-forward "<!--" nil t)
1228 (setq start (- (point) 4))
1229 (search-forward "-->" nil t))
1230 (delete-region start (point))))
1231 (goto-char (point-min))
1232 (while (re-search-forward
1233 "<a href=\"\\(/news/\\)?\\(\\([0-9][0-9]\\)\\([0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([^\\.]+\\).html\\)\"><font size=\"4\"><strong>"
1235 (let ((year (+ 2000 (string-to-number (match-string 3))))
1236 (month (string-to-number (match-string 4)))
1237 (day (string-to-number (match-string 5)))
1238 (id (format "<%s%s%s%s%%%s>"
1243 nnshimbun-current-group))
1244 (url (match-string 2)))
1245 (push (make-full-mail-header
1247 (nnshimbun-mime-encode-string
1248 (mapconcat 'identity
1252 (progn (search-forward "</a>" nil t) (point)))
1255 nnshimbun-from-address
1256 (nnshimbun-make-date-string year month day)
1257 id "" 0 0 (concat nnshimbun-url url))
1259 (nreverse headers)))
1263 ;;; MLs on www.mew.org
1265 (defmacro nnshimbun-mew-concat-url (url)
1266 `(concat nnshimbun-url
1267 (nth 1 (assoc nnshimbun-current-group nnshimbun-mew-groups))
1271 (defmacro nnshimbun-mew-reverse-order-p ()
1272 `(nth 2 (assoc nnshimbun-current-group nnshimbun-mew-groups)))
1274 (defmacro nnshimbun-mew-spew-p ()
1275 `(nth 3 (assoc nnshimbun-current-group nnshimbun-mew-groups)))
1277 (defsubst nnshimbun-mew-retrieve-xover (aux)
1279 (nnshimbun-retrieve-url
1280 (nnshimbun-mew-concat-url (if (= aux 1) "index.html" (format "mail%d.html" aux)))
1283 (defconst nnshimbun-mew-regexp "<A[^>]*HREF=\"\\(msg\\([0-9]+\\).html\\)\">\\([^<]+\\)<")
1285 (defmacro nnshimbun-mew-extract-header-values ()
1287 (setq url (nnshimbun-mew-concat-url (match-string 1))
1288 id (format "<%05d%%%s>"
1289 (1- (string-to-number (match-string 2)))
1290 nnshimbun-current-group)
1291 subject (match-string 3))
1293 (if (nnshimbun-search-id nnshimbun-current-group id)
1294 (throw 'stop headers)
1295 (push (make-full-mail-header
1297 (nnshimbun-mime-encode-string subject)
1298 (if (looking-at "<EM>\\([^<]+\\)<")
1299 (nnshimbun-mime-encode-string (match-string 1))
1305 (if (fboundp 'mime-entity-fetch-field)
1307 (defmacro nnshimbun-mew-mail-header-subject (header)
1308 `(mime-entity-fetch-field ,header 'Subject))
1310 (defalias 'nnshimbun-mew-mail-header-subject 'mail-header-subject)))
1312 (defun nnshimbun-mew-get-headers ()
1313 (if (nnshimbun-mew-spew-p)
1314 (let ((headers (nnshimbun-mew-get-headers-1)))
1316 (insert-buffer-substring (nnshimbun-open-nov nnshimbun-current-group))
1320 (goto-char (point-min))
1321 (let ((subject (nnshimbun-mew-mail-header-subject header))
1323 (while (and (not found)
1324 (search-forward subject nil t))
1325 (if (not (and (search-backward "\t" nil t)
1326 (not (search-backward "\t" (gnus-point-at-bol) t))))
1331 (goto-char (point-max))
1332 (nnheader-insert-nov header)
1335 (nnshimbun-mew-get-headers-1)))
1337 (defun nnshimbun-mew-get-headers-1 ()
1339 (when (re-search-forward
1340 "<A[^>]*HREF=\"mail\\([0-9]+\\)\\.html\">\\[?Last Page\\]?</A>" nil t)
1341 (let ((limit (string-to-number (match-string 1))))
1343 (if (nnshimbun-mew-reverse-order-p)
1345 (while (let (id url subject)
1346 (while (re-search-forward nnshimbun-mew-regexp nil t)
1347 (nnshimbun-mew-extract-header-values))
1349 (nnshimbun-mew-retrieve-xover (setq aux (1+ aux)))))
1351 (nnshimbun-mew-retrieve-xover limit)
1352 (setq limit (1- limit))
1353 (let (id url subject)
1354 (goto-char (point-max))
1355 (while (re-search-backward nnshimbun-mew-regexp nil t)
1356 (nnshimbun-mew-extract-header-values)
1357 (forward-line -2)))))
1362 ;;; MLs on www.xemacs.org
1364 (defmacro nnshimbun-xemacs-concat-url (url)
1365 `(concat nnshimbun-url nnshimbun-current-group "/" ,url))
1367 (defun nnshimbun-xemacs-get-headers ()
1368 (let (headers auxs aux)
1370 (while (re-search-forward
1371 (concat "<A HREF=\"/" nnshimbun-current-group
1372 "/\\([12][0-9][0-9][0-9][0-1][0-9]\\)/\">\\[Index\\]")
1374 (setq auxs (append auxs (list (match-string 1)))))
1377 (nnshimbun-retrieve-url
1378 (nnshimbun-xemacs-concat-url (concat (setq aux (car auxs)) "/")))
1379 (let (id url subject)
1380 (goto-char (point-max))
1381 (while (re-search-backward
1382 "<A[^>]*HREF=\"\\(msg\\([0-9]+\\).html\\)\">\\([^<]+\\)<"
1384 (setq url (nnshimbun-xemacs-concat-url
1385 (concat aux "/" (match-string 1)))
1386 id (format "<%s%05d%%%s>"
1388 (string-to-number (match-string 2))
1389 nnshimbun-current-group)
1390 subject (match-string 3))
1392 (if (nnshimbun-search-id nnshimbun-current-group id)
1393 (throw 'stop headers)
1394 (push (make-full-mail-header
1396 (nnshimbun-mime-encode-string subject)
1397 (if (looking-at "<td><em>\\([^<]+\\)<")
1404 (setq auxs (cdr auxs))))
1407 ;;; MLs on www.jp.netbsd.org
1409 (defun nnshimbun-netbsd-get-headers ()
1410 (let ((case-fold-search t) headers months)
1411 (goto-char (point-min))
1412 (while (re-search-forward "<A HREF=\"\\([0-9]+\\)/\\(threads.html\\)?\">" nil t)
1413 (push (match-string 1) months))
1414 (setq months (nreverse months))
1416 (dolist (month months)
1418 (nnshimbun-retrieve-url
1419 (format "%s%s/%s/maillist.html" nnshimbun-url nnshimbun-current-group month)
1421 (let (id url subject)
1422 (while (re-search-forward
1423 "<A[^>]*HREF=\"\\(msg\\([0-9]+\\)\\.html\\)\">\\([^<]+\\)</A>"
1425 (setq url (format "%s%s/%s/%s"
1427 nnshimbun-current-group
1430 id (format "<%s%05d%%%s>"
1432 (string-to-number (match-string 2))
1433 nnshimbun-current-group)
1434 subject (match-string 3))
1435 (if (nnshimbun-search-id nnshimbun-current-group id)
1436 (throw 'exit headers)
1437 (push (make-full-mail-header
1439 (nnshimbun-mime-encode-string subject)
1440 (if (looking-at "</STRONG> *<EM>\\([^<]+\\)<")
1441 (nnshimbun-mime-encode-string (match-string 1))
1448 (defun nnshimbun-fml-get-headers ()
1449 (let (headers auxs aux)
1451 (while (re-search-forward "<a href=\"\\([0-9]+\\(\\.week\\|\\.month\\)?\\)/index.html\">" nil t)
1452 (setq auxs (append auxs (list (match-string 1)))))
1455 (nnshimbun-retrieve-url
1456 (concat nnshimbun-url (setq aux (car auxs)) "/"))
1457 (subst-char-in-region (point-min) (point-max) ?\t ? t)
1458 (let (id url date subject from)
1459 (goto-char (point-min))
1460 (while (re-search-forward
1461 "<LI><A HREF=\"\\([0-9]+\\.html\\)\">Article .*</A> <DIV><SPAN CLASS=article>Article <SPAN CLASS=article-value>\\([0-9]+\\)</SPAN></SPAN> at <SPAN CLASS=Date-value>\\([^<]*\\)</SPAN> <SPAN CLASS=Subject>Subject: <SPAN CLASS=Subject-value>\\([^<]*\\)</SPAN></SPAN></DIV><DIV><SPAN CLASS=From>From: <SPAN CLASS=From-value>\\([^<]*\\)</SPAN></SPAN></DIV>"
1463 (setq url (concat nnshimbun-url aux "/" (match-string 1))
1464 id (format "<%s%05d%%%s>"
1466 (string-to-number (match-string 2))
1467 nnshimbun-current-group)
1468 date (match-string 3)
1469 subject (match-string 4)
1470 from (match-string 5))
1472 (if (nnshimbun-search-id nnshimbun-current-group id)
1473 (throw 'stop headers)
1474 (push (make-full-mail-header
1476 (nnshimbun-mime-encode-string subject)
1477 from date id "" 0 0 url)
1479 ; (message "%s" id)))
1480 (setq auxs (cdr auxs))))
1483 (provide 'nnshimbun)
1484 ;;; nnshimbun.el ends here.