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 'gnus-clfns))
37 (eval-when-compile (require 'static))
43 (eval-when-compile (ignore-errors (require 'nnweb)))
44 ;; Report failure to find w3 at load time if appropriate.
45 (eval '(require 'nnweb))
49 (nnoo-declare nnshimbun)
51 (defvar nnshimbun-check-interval 300)
53 (defconst nnshimbun-mew-groups
54 '(("meadow-develop" "meadow-develop" nil t)
55 ("meadow-users-jp" "meadow-users-jp")
56 ("mule-win32" "mule-win32")
57 ("mew-win32" "mew-win32")
58 ("mew-dist" "mew-dist/3300" t)
59 ("mgp-users-jp" "mgp-users-jp/A" t t)))
61 (defvar nnshimbun-type-definition
63 (url . "http://spin.asahi.com/")
64 (groups "national" "business" "politics" "international" "sports" "personal" "feneral")
65 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
66 (generate-nov . nnshimbun-generate-nov-for-each-group)
67 (get-headers . nnshimbun-asahi-get-headers)
68 (index-url . (format "%sp%s.html" nnshimbun-url nnshimbun-current-group))
69 (from-address . "webmaster@www.asahi.com")
70 (make-contents . nnshimbun-make-text-or-html-contents)
71 (contents-start . "\n<!-- Start of kiji -->\n")
72 (contents-end . "\n<!-- End of kiji -->\n"))
74 (url . "http://www.sponichi.co.jp/")
75 (groups "baseball" "soccer" "usa" "others" "society" "entertainment" "horseracing")
76 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
77 (generate-nov . nnshimbun-generate-nov-for-each-group)
78 (get-headers . nnshimbun-sponichi-get-headers)
79 (index-url . (format "%s%s/index.html" nnshimbun-url nnshimbun-current-group))
80 (from-address . "webmaster@www.sponichi.co.jp")
81 (make-contents . nnshimbun-make-text-or-html-contents)
82 (contents-start . "\n<span class=\"text\">
\e$B!!
\e(B")
83 (contents-end . "\n"))
85 (url . "http://cnet.sphere.ne.jp/")
87 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
88 (generate-nov . nnshimbun-generate-nov-for-each-group)
89 (get-headers . nnshimbun-cnet-get-headers)
90 (index-url . (format "%s/News/Oneweek/" nnshimbun-url))
91 (from-address . "cnet@sphere.ad.jp")
92 (make-contents . nnshimbun-make-html-contents)
93 (contents-start . "\n<!--KIJI-->\n")
94 (contents-end . "\n<!--/KIJI-->\n"))
96 (url . "http://www.hotwired.co.jp/")
97 (groups "business" "culture" "technology")
98 (coding-system . ,(static-if (boundp 'MULE) '*euc-japan* 'euc-jp))
99 (generate-nov . nnshimbun-generate-nov-for-all-groups)
100 (get-headers . nnshimbun-wired-get-all-headers)
102 (from-address . "webmaster@www.hotwired.co.jp")
103 (make-contents . nnshimbun-make-html-contents)
104 (contents-start . "\n<!-- START_OF_BODY -->\n")
105 (contents-end . "\n<!-- END_OF_BODY -->\n"))
107 (url . "http://www.yomiuri.co.jp/")
108 (groups "shakai" "sports" "seiji" "keizai" "kokusai" "fuho")
109 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
110 (generate-nov . nnshimbun-generate-nov-for-all-groups)
111 (get-headers . nnshimbun-yomiuri-get-all-headers)
112 (index-url . (concat nnshimbun-url "main.htm"))
113 (from-address . "webmaster@www.yomiuri.co.jp")
114 (make-contents . nnshimbun-make-text-or-html-contents)
115 (contents-start . "\n<!-- honbun start -->\n")
116 (contents-end . "\n<!-- honbun end -->\n"))
118 (url . "http://www.zdnet.co.jp/news/")
120 (coding-system . ,(static-if (boundp 'MULE) '*sjis* 'shift_jis))
121 (generate-nov . nnshimbun-generate-nov-for-each-group)
122 (get-headers . nnshimbun-zdnet-get-headers)
123 (index-url . nnshimbun-url)
124 (from-address . "zdnn@softbank.co.jp")
125 (make-contents . nnshimbun-make-html-contents)
126 (contents-start . "\\(<!--BODY-->\\|<!--DATE-->\\)")
127 (contents-end . "\\(<!--BODYEND-->\\|<!--BYLINEEND-->\\)"))
129 (url . "http://www.mew.org/archive/")
130 (groups ,@(mapcar #'car nnshimbun-mew-groups))
131 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
132 (generate-nov . nnshimbun-generate-nov-for-each-group)
133 (get-headers . nnshimbun-mew-get-headers)
134 (index-url . (nnshimbun-mew-concat-url "index.html"))
135 (make-contents . nnshimbun-make-mhonarc-contents))
137 (url . "http://list-archives.xemacs.org/")
138 (groups "xemacs-announce" "xemacs-beta-ja" "xemacs-beta"
139 "xemacs-build-reports" "xemacs-cvs" "xemacs-mule"
140 "xemacs-nt" "xemacs-patches" "xemacs-users-ja" "xemacs")
141 (coding-system . ,(static-if (boundp 'MULE) '*euc-japan* 'euc-jp))
142 (generate-nov . nnshimbun-generate-nov-for-each-group)
143 (get-headers . nnshimbun-xemacs-get-headers)
144 (index-url . (nnshimbun-xemacs-concat-url nil))
145 (make-contents . nnshimbun-make-mhonarc-contents))
147 (url . "http://www.jp.netbsd.org/ja/JP/ml/")
148 (groups "announce-ja" "junk-ja" "tech-misc-ja" "tech-pkg-ja"
149 "port-arm32-ja" "port-hpcmips-ja" "port-mac68k-ja"
150 "port-mips-ja" "port-powerpc-ja" "hpcmips-changes-ja"
151 "members-ja" "admin-ja" "www-changes-ja")
152 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
153 (generate-nov . nnshimbun-generate-nov-for-each-group)
154 (get-headers . nnshimbun-netbsd-get-headers)
155 (index-url . (format "%s%s/index.html" nnshimbun-url nnshimbun-current-group))
156 (make-contents . nnshimbun-make-mhonarc-contents))
158 (url . "http://www.rc.tutrp.tut.ac.jp/bbdb-ml/")
160 (coding-system . ,(static-if (boundp 'MULE) '*iso-2022-jp* 'iso-2022-jp))
161 (generate-nov . nnshimbun-generate-nov-for-each-group)
162 (get-headers . nnshimbun-fml-get-headers)
163 (index-url . nnshimbun-url)
164 (make-contents . nnshimbun-make-fml-contents))
167 (defvar nnshimbun-x-face-alist
170 "X-Face: Ygq$6P.,%Xt$U)DS)cRY@k$VkW!7(X'X'?U{{osjjFG\"E]hND;SPJ-J?O?R|a?L
171 g2$0rVng=O3Lt}?~IId8Jj&vP^3*o=LKUyk(`t%0c!;t6REk=JbpsEn9MrN7gZ%"))))
172 "Alist of server vs. alist of group vs. X-Face field. It looks like:
174 \((\"asahi\" . ((\"national\" . \"X-face: ***\")
175 (\"business\" . \"X-Face: ***\")
178 (\"default\" . \"X-face: ***\")))
179 (\"sponichi\" . ((\"baseball\" . \"X-face: ***\")
180 (\"soccer\" . \"X-Face: ***\")
183 (\"default\" . \"X-face: ***\")))
185 (\"default\" . ((\"default\" . \"X-face: ***\")))")
187 (defvoo nnshimbun-directory (nnheader-concat gnus-directory "shimbun/")
188 "Where nnshimbun will save its files.")
190 (defvoo nnshimbun-nov-is-evil nil
191 "*Non-nil means that nnshimbun will never retrieve NOV headers.")
193 (defvoo nnshimbun-nov-file-name ".overview")
195 (defvoo nnshimbun-pre-fetch-article nil
196 "*Non nil means that nnshimbun fetch unread articles when scanning groups.")
198 ;; set by nnshimbun-possibly-change-group
199 (defvoo nnshimbun-buffer nil)
200 (defvoo nnshimbun-current-directory nil)
201 (defvoo nnshimbun-current-group nil)
203 ;; set by nnshimbun-open-server
204 (defvoo nnshimbun-url nil)
205 (defvoo nnshimbun-coding-system nil)
206 (defvoo nnshimbun-groups nil)
207 (defvoo nnshimbun-generate-nov nil)
208 (defvoo nnshimbun-get-headers nil)
209 (defvoo nnshimbun-index-url nil)
210 (defvoo nnshimbun-from-address nil)
211 (defvoo nnshimbun-make-contents nil)
212 (defvoo nnshimbun-contents-start nil)
213 (defvoo nnshimbun-contents-end nil)
214 (defvoo nnshimbun-server-directory nil)
216 (defvoo nnshimbun-status-string "")
217 (defvoo nnshimbun-nov-last-check nil)
218 (defvoo nnshimbun-nov-buffer-alist nil)
219 (defvoo nnshimbun-nov-buffer-file-name nil)
221 (defvoo nnshimbun-keep-backlog 300)
222 (defvoo nnshimbun-backlog-articles nil)
223 (defvoo nnshimbun-backlog-hashtb nil)
225 (defconst nnshimbun-meta-content-type-charset-regexp
227 (concat "<meta[ \t]+http-equiv=\"?Content-type\"?[ \t]+content=\"\\([^;]+\\)"
228 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
230 "Regexp used in parsing `<META HTTP-EQUIV=\"Content-Type\" content=\"...;charset=...\">
231 for a charset indication")
233 (defconst nnshimbun-meta-charset-content-type-regexp
235 (concat "<meta[ \t]+content=\"\\([^;]+\\)"
236 ";[ \t]*charset=\"?\\([^\"]+\\)\"?"
237 "[ \t]+http-equiv=\"?Content-type\"?>"))
238 "Regexp used in parsing `<META content=\"...;charset=...\" HTTP-EQUIV=\"Content-Type\">
239 for a charset indication")
244 (defmacro nnshimbun-backlog (&rest form)
245 `(let ((gnus-keep-backlog nnshimbun-keep-backlog)
246 (gnus-backlog-buffer (format " *nnshimbun backlog %s*" (nnoo-current-server 'nnshimbun)))
247 (gnus-backlog-articles nnshimbun-backlog-articles)
248 (gnus-backlog-hashtb nnshimbun-backlog-hashtb))
251 (setq nnshimbun-backlog-articles gnus-backlog-articles
252 nnshimbun-backlog-hashtb gnus-backlog-hashtb))))
253 (put 'nnshimbun-backlog 'lisp-indent-function 0)
254 (put 'nnshimbun-backlog 'edebug-form-spec '(form body))
258 ;;; Interface Functions
259 (nnoo-define-basics nnshimbun)
261 (deffoo nnshimbun-open-server (server &optional defs)
262 ;; Set default values.
263 (dolist (default (cdr (assoc server nnshimbun-type-definition)))
264 (let ((symbol (intern (concat "nnshimbun-" (symbol-name (car default))))))
265 (unless (assq symbol defs)
266 (push (list symbol (cdr default)) defs))))
267 ;; Set directory for server working files.
268 (push (list 'nnshimbun-server-directory
269 (file-name-as-directory
270 (expand-file-name server nnshimbun-directory)))
272 (nnoo-change-server 'nnshimbun server defs)
273 (nnshimbun-possibly-change-group nil server)
275 (unless (file-exists-p nnshimbun-directory)
276 (ignore-errors (make-directory nnshimbun-directory t)))
278 ((not (file-exists-p nnshimbun-directory))
279 (nnshimbun-close-server)
280 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-directory))
281 ((not (file-directory-p (file-truename nnshimbun-directory)))
282 (nnshimbun-close-server)
283 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-directory))
285 (unless (file-exists-p nnshimbun-server-directory)
286 (ignore-errors (make-directory nnshimbun-server-directory t)))
288 ((not (file-exists-p nnshimbun-server-directory))
289 (nnshimbun-close-server)
290 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-server-directory))
291 ((not (file-directory-p (file-truename nnshimbun-server-directory)))
292 (nnshimbun-close-server)
293 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-server-directory))
295 (nnheader-report 'nnshimbun "Opened server %s using directory %s"
296 server nnshimbun-server-directory)
299 (deffoo nnshimbun-close-server (&optional server)
300 (and (nnshimbun-server-opened server)
301 (gnus-buffer-live-p nnshimbun-buffer)
302 (kill-buffer nnshimbun-buffer))
303 (nnshimbun-backlog (gnus-backlog-shutdown))
305 (nnoo-close-server 'nnshimbun server)
308 (static-when (boundp 'MULE)
309 (unless (coding-system-p 'euc-japan)
310 (copy-coding-system '*euc-japan* 'euc-japan))
311 (unless (coding-system-p 'shift_jis)
312 (copy-coding-system '*sjis* 'shift_jis))
314 (defalias-maybe 'coding-system-category 'get-code-mnemonic)))
316 (defun nnshimbun-retrieve-url (url &optional no-cache)
317 "Rertrieve URL contents and insert to current buffer."
318 (let ((buf (current-buffer))
319 (url-working-buffer url-working-buffer))
320 (let ((old-asynch (default-value 'url-be-asynchronous))
321 (old-caching (default-value 'url-automatic-caching))
322 (old-mode (default-value 'url-standalone-mode)))
323 (setq-default url-be-asynchronous nil)
325 (setq-default url-automatic-caching nil)
326 (setq-default url-standalone-mode nil))
328 (let ((coding-system-for-read 'binary)
329 (coding-system-for-write 'binary)
330 (input-coding-system 'binary)
331 (output-coding-system 'binary)
332 (default-enable-multibyte-characters nil))
334 (setq url-working-buffer
335 (cdr (url-retrieve url no-cache))))
337 (setq-default url-be-asynchronous old-asynch)
338 (setq-default url-automatic-caching old-caching)
339 (setq-default url-standalone-mode old-mode)))
341 (or url-current-mime-charset
342 (let ((case-fold-search t))
343 (goto-char (point-min))
344 (if (or (re-search-forward
345 nnshimbun-meta-content-type-charset-regexp nil t)
347 nnshimbun-meta-charset-content-type-regexp nil t))
348 (buffer-substring-no-properties (match-beginning 2)
350 (decode-coding-region
351 (point-min) (point-max)
353 (let ((mime-charset-coding-system-alist
354 (append '((euc-jp . euc-japan)
355 (shift-jis . shift_jis)
356 (shift_jis . shift_jis)
358 (x-euc-jp . euc-japan)
359 (x-shift-jis . shift_jis)
360 (x-shift_jis . shift_jis)
361 (x-sjis . shift_jis))
362 mime-charset-coding-system-alist)))
363 (mime-charset-to-coding-system charset))
364 (let ((default (condition-case nil
365 (coding-system-category nnshimbun-coding-system)
367 (candidate (detect-coding-region (point-min) (point-max))))
368 (unless (listp candidate)
369 (setq candidate (list candidate)))
371 (dolist (coding candidate)
372 (if (eq default (coding-system-category coding))
373 (throw 'coding coding)))
374 (if (eq (coding-system-category 'binary)
375 (coding-system-category (car candidate)))
376 nnshimbun-coding-system
377 (car candidate)))))))
378 (set-buffer-multibyte t)
380 (insert-buffer url-working-buffer)
381 (kill-buffer url-working-buffer)))
383 (deffoo nnshimbun-request-article (article &optional group server to-buffer)
384 (when (nnshimbun-possibly-change-group group server)
385 (if (stringp article)
386 (setq article (nnshimbun-search-id group article)))
387 (if (integerp article)
388 (nnshimbun-request-article-1 article group server to-buffer)
389 (nnheader-report 'nnml "Couldn't retrieve article: %s" (prin1-to-string article))
392 (defsubst nnshimbun-header-xref (x)
393 (if (and (setq x (mail-header-xref x))
394 (string-match "^Xref: " x))
398 (defun nnshimbun-request-article-1 (article &optional group server to-buffer)
399 (if (nnshimbun-backlog
400 (gnus-backlog-request-article
401 group article (or to-buffer nntp-server-buffer)))
403 (let (header contents)
404 (when (setq header (save-excursion
405 (set-buffer (nnshimbun-open-nov group))
406 (and (nnheader-find-nov-line article)
407 (nnheader-parse-nov))))
408 (let* ((xref (nnshimbun-header-xref header))
409 (x-faces (cdr (or (assoc (or server
410 (nnoo-current-server 'nnshimbun))
411 nnshimbun-x-face-alist)
412 (assoc "default" nnshimbun-x-face-alist))))
413 (x-face (cdr (or (assoc group x-faces)
414 (assoc "default" x-faces)))))
416 (set-buffer nnshimbun-buffer)
418 (nnshimbun-retrieve-url xref)
419 (nnheader-message 6 "nnshimbun: Make contents...")
420 (goto-char (point-min))
421 (setq contents (funcall nnshimbun-make-contents header x-face))
422 (nnheader-message 6 "nnshimbun: Make contents...done"))))
425 (set-buffer (or to-buffer nntp-server-buffer))
429 (gnus-backlog-enter-article group article (current-buffer)))
430 (nnheader-report 'nnshimbun "Article %s retrieved" (mail-header-id header))
431 (cons group (mail-header-number header)))))))
433 (deffoo nnshimbun-request-group (group &optional server dont-check)
434 (let ((pathname-coding-system 'binary))
436 ((not (nnshimbun-possibly-change-group group server))
437 (nnheader-report 'nnshimbun "Invalid group (no such directory)"))
438 ((not (file-exists-p nnshimbun-current-directory))
439 (nnheader-report 'nnshimbun "Directory %s does not exist"
440 nnshimbun-current-directory))
441 ((not (file-directory-p nnshimbun-current-directory))
442 (nnheader-report 'nnshimbun "%s is not a directory" nnshimbun-current-directory))
444 (nnheader-report 'nnshimbun "Group %s selected" group)
449 (set-buffer (nnshimbun-open-nov group))
450 (goto-char (point-min))
451 (setq beg (ignore-errors (read (current-buffer))))
452 (goto-char (point-max))
454 (setq end (ignore-errors (read (current-buffer)))
455 lines (count-lines (point-min) (point-max))))
456 (nnheader-report 'nnshimbunw "Selected group %s" group)
457 (nnheader-insert "211 %d %d %d %s\n"
458 lines (or beg 0) (or end 0) group))))))
460 (deffoo nnshimbun-request-scan (&optional group server)
461 (nnshimbun-possibly-change-group group server)
462 (nnshimbun-generate-nov-database group))
464 (deffoo nnshimbun-close-group (group &optional server)
465 (nnshimbun-write-nov group)
468 (deffoo nnshimbun-request-list (&optional server)
470 (set-buffer nntp-server-buffer)
472 (dolist (group nnshimbun-groups)
473 (when (nnshimbun-possibly-change-group group server)
476 (set-buffer (nnshimbun-open-nov group))
477 (goto-char (point-min))
478 (setq beg (ignore-errors (read (current-buffer))))
479 (goto-char (point-max))
481 (setq end (ignore-errors (read (current-buffer)))))
482 (insert (format "%s %d %d n\n" group (or end 0) (or beg 0)))))))
486 (if (fboundp 'mime-entity-fetch-field)
488 (defun nnshimbun-insert-header (header)
489 (insert "Subject: " (or (mime-entity-fetch-field header 'Subject) "(none)") "\n"
490 "From: " (or (mime-entity-fetch-field header 'From) "(nobody)") "\n"
491 "Date: " (or (mail-header-date header) "") "\n"
492 "Message-ID: " (or (mail-header-id header) (nnmail-message-id)) "\n")
493 (let ((refs (mail-header-references header)))
496 (insert "References: " refs "\n")))
497 (insert "Lines: " (number-to-string (or (mail-header-lines header) 0)) "\n"
498 "Xref: " (nnshimbun-header-xref header) "\n"))
500 (defun nnshimbun-insert-header (header)
501 (nnheader-insert-header header)
503 (insert "Xref: " (nnshimbun-header-xref header) "\n"))))
505 (deffoo nnshimbun-retrieve-headers (articles &optional group server fetch-old)
506 (when (nnshimbun-possibly-change-group group server)
507 (if (nnshimbun-retrieve-headers-with-nov articles fetch-old)
510 (set-buffer nntp-server-buffer)
513 (dolist (art articles)
515 (setq art (nnshimbun-search-id group art)))
519 (set-buffer (nnshimbun-open-nov group))
520 (and (nnheader-find-nov-line art)
521 (nnheader-parse-nov))))
522 (insert (format "220 %d Article retrieved.\n" art))
523 (nnshimbun-insert-header header)
525 (delete-region (point) (point-max))))))
528 (defun nnshimbun-retrieve-headers-with-nov (articles &optional fetch-old)
529 (if (or gnus-nov-is-evil nnshimbun-nov-is-evil)
531 (let ((nov (expand-file-name nnshimbun-nov-file-name nnshimbun-current-directory)))
532 (when (file-exists-p nov)
534 (set-buffer nntp-server-buffer)
536 (nnheader-insert-file-contents nov)
537 (if (and fetch-old (not (numberp fetch-old)))
538 t ; Don't remove anything.
539 (nnheader-nov-delete-outside-range
540 (if fetch-old (max 1 (- (car articles) fetch-old))
542 (car (last articles)))
547 ;;; Nov Database Operations
549 (defun nnshimbun-generate-nov-database (group)
550 (prog1 (funcall nnshimbun-generate-nov group)
551 (nnshimbun-write-nov group)))
553 (defun nnshimbun-generate-nov-for-each-group (group)
554 (nnshimbun-possibly-change-group group)
556 (set-buffer (nnshimbun-open-nov group))
558 (goto-char (point-max))
560 (setq i (or (ignore-errors (read (current-buffer))) 0))
561 (dolist (header (save-excursion
562 (set-buffer nnshimbun-buffer)
564 (nnshimbun-retrieve-url (eval nnshimbun-index-url) t)
565 (goto-char (point-min))
566 (funcall nnshimbun-get-headers)))
567 (unless (nnshimbun-search-id group (mail-header-id header))
568 (mail-header-set-number header (setq i (1+ i)))
569 (goto-char (point-max))
570 (nnheader-insert-nov header)
571 (if nnshimbun-pre-fetch-article
572 (nnshimbun-request-article-1 i group nil nnshimbun-buffer)))))))
574 (defun nnshimbun-generate-nov-for-all-groups (&rest args)
575 (unless (and nnshimbun-nov-last-check
576 (< (nnshimbun-lapse-seconds nnshimbun-nov-last-check)
577 nnshimbun-check-interval))
579 (dolist (list (funcall nnshimbun-get-headers))
580 (let ((group (car list)))
581 (nnshimbun-possibly-change-group group)
583 (set-buffer (nnshimbun-open-nov group))
585 (goto-char (point-max))
587 (setq i (or (ignore-errors (read (current-buffer))) 0))
588 (dolist (header (cdr list))
589 (unless (nnshimbun-search-id group (mail-header-id header))
590 (mail-header-set-number header (setq i (1+ i)))
591 (goto-char (point-max))
592 (nnheader-insert-nov header)
593 (if nnshimbun-pre-fetch-article
594 (nnshimbun-request-article-1 i group nil nnshimbun-buffer))))))))
596 (setq nnshimbun-nov-last-check (current-time)))))
598 (defun nnshimbun-search-id (group id &optional nov)
600 (set-buffer (nnshimbun-open-nov group))
601 (goto-char (point-min))
603 (while (and (not found)
604 (search-forward id nil t)) ; We find the ID.
605 ;; And the id is in the fourth field.
606 (if (not (and (search-backward "\t" nil t 4)
607 (not (search-backward "\t" (gnus-point-at-bol) t))))
612 (goto-char (point-min))
613 (when (search-forward (concat "X-Nnshimbun-Id: " id) nil t)
619 ;; We return the article number.
620 (ignore-errors (read (current-buffer))))))))
622 (defun nnshimbun-nov-fix-header (group header args)
624 (set-buffer (nnshimbun-open-nov group))
625 (when (nnheader-find-nov-line (mail-header-number header))
627 (if (eq (car arg) 'id)
628 (let ((extra (mail-header-extra header)))
629 (unless (assq 'X-Nnshimbun-Id extra)
630 (mail-header-set-extra
632 (cons (cons 'X-Nnshimbun-Id (mail-header-id header))
634 (mail-header-set-id header (cdr arg)))
635 (let ((func (intern (concat "mail-header-set-" (symbol-name (car arg))))))
636 (if (cdr arg) (eval (list func header (cdr arg)))))))
637 (mail-header-set-xref header (nnshimbun-header-xref header))
638 (delete-region (point) (progn (forward-line 1) (point)))
639 (nnheader-insert-nov header))))
641 (defun nnshimbun-open-nov (group)
642 (let ((buffer (cdr (assoc group nnshimbun-nov-buffer-alist))))
643 (if (buffer-live-p buffer)
645 (setq buffer (gnus-get-buffer-create
646 (format " *nnshimbun overview %s %s*"
647 (nnoo-current-server 'nnshimbun) group)))
650 (set (make-local-variable 'nnshimbun-nov-buffer-file-name)
652 nnshimbun-nov-file-name
653 (nnmail-group-pathname group nnshimbun-server-directory)))
655 (when (file-exists-p nnshimbun-nov-buffer-file-name)
656 (nnheader-insert-file-contents nnshimbun-nov-buffer-file-name))
657 (set-buffer-modified-p nil))
658 (push (cons group buffer) nnshimbun-nov-buffer-alist)
661 (defun nnshimbun-write-nov (group)
662 (let ((buffer (cdr (assoc group nnshimbun-nov-buffer-alist))))
663 (when (buffer-live-p buffer)
667 (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
670 (defun nnshimbun-save-nov ()
672 (while nnshimbun-nov-buffer-alist
673 (when (buffer-name (cdar nnshimbun-nov-buffer-alist))
674 (set-buffer (cdar nnshimbun-nov-buffer-alist))
675 (when (buffer-modified-p)
676 (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
678 (set-buffer-modified-p nil)
679 (kill-buffer (current-buffer)))
680 (setq nnshimbun-nov-buffer-alist (cdr nnshimbun-nov-buffer-alist)))))
684 ;;; Server Initialize
685 (defun nnshimbun-possibly-change-group (group &optional server)
687 (unless (nnshimbun-server-opened server)
688 (nnshimbun-open-server server)))
689 (unless (gnus-buffer-live-p nnshimbun-buffer)
690 (setq nnshimbun-buffer
692 (nnheader-set-temp-buffer
693 (format " *nnshimbun %s*" (nnoo-current-server 'nnshimbun))))))
696 (let ((pathname (nnmail-group-pathname group nnshimbun-server-directory))
697 (pathname-coding-system 'binary))
698 (unless (equal pathname nnshimbun-current-directory)
699 (setq nnshimbun-current-directory pathname
700 nnshimbun-current-group group))
701 (unless (file-exists-p nnshimbun-current-directory)
702 (ignore-errors (make-directory nnshimbun-current-directory t)))
704 ((not (file-exists-p nnshimbun-current-directory))
705 (nnheader-report 'nnshimbun "Couldn't create directory: %s" nnshimbun-current-directory))
706 ((not (file-directory-p (file-truename nnshimbun-current-directory)))
707 (nnheader-report 'nnshimbun "Not a directory: %s" nnshimbun-current-directory))
715 (if (fboundp 'eword-encode-string)
717 (defun nnshimbun-mime-encode-string (string)
720 (split-string (eword-encode-string (nnweb-decode-entities-string string)) "\n")
723 (defun nnshimbun-mime-encode-string (string)
728 (insert (nnweb-decode-entities-string string))
729 (rfc2047-encode-region (point-min) (point-max))
730 (buffer-substring (point-min) (point-max)))
734 (defun nnshimbun-lapse-seconds (time)
735 (let ((now (current-time)))
736 (+ (* (- (car now) (car time)) 65536)
737 (- (nth 1 now) (nth 1 time)))))
739 (defun nnshimbun-make-date-string (year month day &optional time)
740 (format "%02d %s %04d %s +0900"
742 (aref [nil "Jan" "Feb" "Mar" "Apr" "May" "Jun"
743 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"]
749 ((< year 1000) ; possible 3-digit years.
754 (if (fboundp 'regexp-opt)
755 (defalias 'nnshimbun-regexp-opt 'regexp-opt)
756 (defun nnshimbun-regexp-opt (strings &optional paren)
757 "Return a regexp to match a string in STRINGS.
758 Each string should be unique in STRINGS and should not contain any regexps,
759 quoted or not. If optional PAREN is non-nil, ensure that the returned regexp
760 is enclosed by at least one regexp grouping construct."
761 (let ((open-paren (if paren "\\(" "")) (close-paren (if paren "\\)" "")))
762 (concat open-paren (mapconcat 'regexp-quote strings "\\|") close-paren))))
765 ;; Fast fill-region function
767 (defvar nnshimbun-fill-column (min 80 (- (frame-width) 4)))
769 (defconst nnshimbun-kinsoku-bol-list
770 (append "!)-_~}]:;',.?
\e$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7
\e(B\
771 \e$B!8!9!:!;!<!=!>!?!@!A!B!C!D!E!G!I!K!M!O!Q!S!U!W!Y![!k!l!m!n$!$#$%$'$)
\e(B\
772 \e$B$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v
\e(B" nil))
774 (defconst nnshimbun-kinsoku-eol-list
775 (append "({[`
\e$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!x
\e(B" nil))
777 (defun nnshimbun-fill-line ()
779 (let ((top (point)) chr)
780 (while (if (>= (move-to-column nnshimbun-fill-column)
781 nnshimbun-fill-column)
783 (if (memq (preceding-char) nnshimbun-kinsoku-eol-list)
786 (while (memq (preceding-char) nnshimbun-kinsoku-eol-list)
789 (while (memq (setq chr (following-char)) nnshimbun-kinsoku-bol-list)
791 (if (looking-at "\\s-+")
792 (or (eolp) (delete-region (point) (match-end 0)))
793 (or (> (char-width chr) 1)
794 (re-search-backward "\\<" top t)
796 (or (eolp) (insert "\n"))))))
801 (defsubst nnshimbun-shallow-rendering ()
802 (goto-char (point-min))
803 (while (search-forward "<p>" nil t)
805 (goto-char (point-min))
806 (while (search-forward "<br>" nil t)
808 (nnweb-remove-markup)
809 (nnweb-decode-entities)
810 (goto-char (point-min))
811 (while (nnshimbun-fill-line))
812 (goto-char (point-min))
813 (when (skip-chars-forward "\n")
814 (delete-region (point-min) (point)))
815 (while (search-forward "\n\n" nil t)
817 (when (skip-chars-forward "\n")
818 (delete-region p (point)))))
819 (goto-char (point-max))
820 (when (skip-chars-backward "\n")
821 (delete-region (point) (point-max)))
824 (defun nnshimbun-make-text-or-html-contents (header &optional x-face)
825 (let ((case-fold-search t) (html t) (start))
826 (when (and (re-search-forward nnshimbun-contents-start nil t)
828 (re-search-forward nnshimbun-contents-end nil t))
829 (delete-region (match-beginning 0) (point-max))
830 (delete-region (point-min) start)
831 (nnshimbun-shallow-rendering)
833 (goto-char (point-min))
834 (nnshimbun-insert-header header)
835 (insert "Content-Type: " (if html "text/html" "text/plain")
836 "; charset=ISO-2022-JP\nMIME-Version: 1.0\n")
842 (encode-coding-string (buffer-string)
843 (mime-charset-to-coding-system "ISO-2022-JP"))))
845 (defun nnshimbun-make-html-contents (header &optional x-face)
847 (when (and (re-search-forward nnshimbun-contents-start nil t)
849 (re-search-forward nnshimbun-contents-end nil t))
850 (delete-region (match-beginning 0) (point-max))
851 (delete-region (point-min) start))
852 (goto-char (point-min))
853 (nnshimbun-insert-header header)
854 (insert "Content-Type: text/html; charset=ISO-2022-JP\n"
855 "MIME-Version: 1.0\n")
861 (encode-coding-string (buffer-string)
862 (mime-charset-to-coding-system "ISO-2022-JP"))))
864 (defun nnshimbun-make-mhonarc-contents (header &rest args)
866 (if (search-forward "<!--X-Head-End-->" nil t)
869 ;; Processing headers.
871 (narrow-to-region (point-min) (point))
872 (nnweb-decode-entities)
873 (goto-char (point-min))
874 (while (search-forward "\n<!--X-" nil t)
875 (replace-match "\n"))
876 (goto-char (point-min))
877 (while (search-forward " -->\n" nil t)
878 (replace-match "\n"))
879 (goto-char (point-min))
880 (while (search-forward "\t" nil t)
882 (goto-char (point-min))
887 (delete-region (point) (progn (forward-line 1) (point))))
888 ((looking-at "Subject: +")
889 (push (cons 'subject (nnheader-header-value)) buf)
890 (delete-region (point) (progn (forward-line 1) (point))))
891 ((looking-at "From: +")
892 (push (cons 'from (nnheader-header-value)) buf)
893 (delete-region (point) (progn (forward-line 1) (point))))
894 ((looking-at "Date: +")
895 (push (cons 'date (nnheader-header-value)) buf)
896 (delete-region (point) (progn (forward-line 1) (point))))
897 ((looking-at "Message-Id: +")
898 (push (cons 'id (concat "<" (nnheader-header-value) ">")) buf)
899 (delete-region (point) (progn (forward-line 1) (point))))
900 ((looking-at "Reference: +")
901 (push (concat "<" (nnheader-header-value) ">") refs)
902 (delete-region (point) (progn (forward-line 1) (point))))
903 ((looking-at "Content-Type: ")
904 (unless (search-forward "charset" (gnus-point-at-eol) t)
906 (insert "; charset=ISO-2022-JP"))
908 (t (forward-line 1))))
909 (insert "MIME-Version: 1.0\n")
910 (if refs (push (cons 'references (mapconcat 'identity refs " ")) buf))
911 (nnshimbun-nov-fix-header nnshimbun-current-group header buf)
912 (goto-char (point-min))
913 (nnshimbun-insert-header header))
914 (goto-char (point-max)))
917 (narrow-to-region (point) (point-max))
921 (search-forward "\n<!--X-Body-of-Message-->\n" nil t)
923 (when (search-forward "\n<!--X-Body-of-Message-End-->\n" nil t)
925 (delete-region (point) (point-max)))
926 (nnweb-remove-markup)
927 (nnweb-decode-entities)))
928 (goto-char (point-min))
929 (nnshimbun-insert-header header)
930 (insert "Content-Type: text/html; charset=ISO-2022-JP\nMIME-Version: 1.0\n\n"))
931 (encode-coding-string (buffer-string)
932 (mime-charset-to-coding-system "ISO-2022-JP")))
934 (defun nnshimbun-make-fml-contents (header &rest args)
937 (if (search-forward "<SPAN CLASS=mailheaders>" nil t)
938 (delete-region (point-min) (point))
940 (if (search-forward "</PRE>")
943 (delete-region (point) (point-max)))
945 (if (search-backward "</SPAN>")
951 (narrow-to-region (point-min) (point))
952 (subst-char-in-region (point-min) (point-max) ?\t ? t)
953 (nnweb-decode-entities)
954 (goto-char (point-min))
955 (let (buf field value start value-beg end)
956 (while (and (setq start (point))
957 (re-search-forward "<SPAN CLASS=\\(.*\\)>\\(.*\\)</SPAN>:"
959 (setq field (match-string 2))
961 (concat "<SPAN CLASS=" (match-string 1) "-value>") nil t)
962 (setq value-beg (point))
963 (search-forward "</SPAN>" nil t)
965 (setq value (buffer-substring value-beg
966 (progn (search-backward "</SPAN>")
968 (delete-region start end)
969 (cond ((string= field "Date")
970 (push (cons 'date value) buf))
971 ((string= field "From")
972 (push (cons 'from value) buf))
973 ((string= field "Subject")
974 (push (cons 'subject value) buf))
975 ((string= field "Message-Id")
976 (push (cons 'id value) buf))
977 ((string= field "References")
978 (push (cons 'references value) buf))
980 (insert (concat field ": " value "\n")))))
981 (nnshimbun-nov-fix-header nnshimbun-current-group header buf)
982 (goto-char (point-min))
983 (nnshimbun-insert-header header))
984 (goto-char (point-max)))
987 (narrow-to-region (point) (point-max))
988 (nnweb-remove-markup)
989 (nnweb-decode-entities)))
990 (encode-coding-string (buffer-string)
991 (mime-charset-to-coding-system "ISO-2022-JP")))
995 (defun nnshimbun-asahi-get-headers ()
996 (when (search-forward "\n<!-- Start of past -->\n" nil t)
997 (delete-region (point-min) (point))
998 (when (search-forward "\n<!-- End of past -->\n" nil t)
1000 (delete-region (point) (point-max))
1001 (goto-char (point-min))
1003 (while (re-search-forward
1004 "^
\e$B"#
\e(B<a href=\"\\(\\([0-9][0-9][0-9][0-9]\\)/past/\\([A-z]*[0-9]*\\)\\.html\\)\"> *"
1006 (let ((id (format "<%s%s%%%s>"
1009 nnshimbun-current-group))
1010 (url (match-string 1)))
1011 (push (make-full-mail-header
1013 (nnshimbun-mime-encode-string
1014 (mapconcat 'identity
1018 (progn (search-forward "<br>" nil t) (point)))
1019 "\\(<[^>]+>\\|\r\\)")
1021 nnshimbun-from-address
1022 "" id "" 0 0 (concat nnshimbun-url url))
1024 (setq headers (nreverse headers))
1026 (while (and (nth i headers)
1028 "^\\[\\([0-9][0-9]\\)/\\([0-9][0-9]\\) \\([0-9][0-9]:[0-9][0-9]\\)\\]"
1030 (let ((month (string-to-number (match-string 1)))
1031 (date (decode-time (current-time))))
1032 (mail-header-set-date
1034 (nnshimbun-make-date-string
1035 (if (and (eq 12 month) (eq 1 (nth 4 date)))
1039 (string-to-number (match-string 2))
1042 (nreverse headers)))))
1046 ;;; www.sponichi.co.jp
1048 (defun nnshimbun-sponichi-get-headers ()
1049 (when (search-forward "
\e$B%K%e!<%9%$%s%G%C%/%9
\e(B" nil t)
1050 (delete-region (point-min) (point))
1051 (when (search-forward "
\e$B%"%I%?%0
\e(B" nil t)
1053 (delete-region (point) (point-max))
1054 (goto-char (point-min))
1055 (let ((case-fold-search t) headers)
1056 (while (re-search-forward
1057 "^<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\\)\">"
1059 (let ((url (match-string 1))
1060 (id (format "<%s%s%s%s%%%s>"
1065 nnshimbun-current-group))
1066 (date (nnshimbun-make-date-string
1067 (string-to-number (match-string 3))
1068 (string-to-number (match-string 4))
1069 (string-to-number (match-string 5)))))
1070 (push (make-full-mail-header
1072 (nnshimbun-mime-encode-string
1073 (mapconcat 'identity
1077 (progn (search-forward "<br>" nil t) (point)))
1080 nnshimbun-from-address
1081 date id "" 0 0 (concat nnshimbun-url url))
1089 (defun nnshimbun-cnet-get-headers ()
1090 (let ((case-fold-search t) headers)
1091 (while (search-forward "\n<!--*****
\e$B8+=P$7
\e(B*****-->\n" nil t)
1092 (let ((subject (buffer-substring (point) (gnus-point-at-eol)))
1095 (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\\)\">")
1096 (let ((url (match-string 1))
1097 (id (format "<%s%s%%%s>"
1100 nnshimbun-current-group))
1101 (date (nnshimbun-make-date-string
1102 (string-to-number (match-string 2))
1103 (string-to-number (match-string 4))
1104 (string-to-number (match-string 5)))))
1105 (push (make-full-mail-header
1107 (nnshimbun-mime-encode-string subject)
1108 nnshimbun-from-address
1109 date id "" 0 0 (concat nnshimbun-url url))
1118 (defun nnshimbun-wired-get-all-headers ()
1120 (set-buffer nnshimbun-buffer)
1121 (let ((group-header-alist (mapcar (lambda (g) (cons g nil)) nnshimbun-groups))
1122 (case-fold-search t)
1124 "<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>"
1125 (regexp-quote nnshimbun-url)
1126 (nnshimbun-regexp-opt nnshimbun-groups))))
1127 (dolist (xover (list (concat nnshimbun-url "news/news/index.html")
1128 (concat nnshimbun-url "news/news/last_seven.html")))
1130 (nnshimbun-retrieve-url xover t)
1131 (goto-char (point-min))
1132 (while (re-search-forward regexp nil t)
1133 (let* ((url (concat nnshimbun-url (match-string 2)))
1134 (group (downcase (match-string 3)))
1135 (id (format "<%s%%%s>" (match-string 4) group))
1136 (date (nnshimbun-make-date-string
1137 (string-to-number (match-string 5))
1138 (string-to-number (match-string 6))
1139 (string-to-number (match-string 7))))
1140 (header (make-full-mail-header
1142 (nnshimbun-mime-encode-string
1143 (mapconcat 'identity
1147 (progn (search-forward "</b>" nil t) (point)))
1150 nnshimbun-from-address
1151 date id "" 0 0 url))
1152 (x (assoc group group-header-alist)))
1153 (setcdr x (cons header (cdr x))))))
1154 group-header-alist)))
1158 ;;; www.yomiuri.co.jp
1160 (defun nnshimbun-yomiuri-get-all-headers ()
1162 (set-buffer nnshimbun-buffer)
1164 (nnshimbun-retrieve-url (eval nnshimbun-index-url) t)
1165 (let ((case-fold-search t)
1166 (group-header-alist (mapcar (lambda (g) (cons g nil)) nnshimbun-groups)))
1167 (dolist (group nnshimbun-groups)
1169 (goto-char (point-min))
1170 (when (and (search-forward (format "\n<!-- /news/%s=start -->\n" group) nil t)
1171 (setq start (point))
1172 (search-forward (format "\n<!-- /news/%s=end -->\n" group) nil t))
1175 (narrow-to-region start (point))
1177 (while (re-search-forward
1178 "<a href=\"/\\([0-9]+\\)/\\(\\(\\([0-9][0-9][0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)[A-z0-9]+\\)\\.htm\\)\"[^>]*>"
1180 (let ((url (concat (match-string 1) "a/" (match-string 2)))
1181 (id (format "<%s%s%%%s>"
1185 (year (string-to-number (match-string 4)))
1186 (month (string-to-number (match-string 5)))
1187 (day (string-to-number (match-string 6)))
1193 (progn (search-forward "<br>" nil t) (point)))
1197 (when (string-match "^
\e$B"!
\e(B" subject)
1198 (setq subject (substring subject (match-end 0))))
1199 (if (string-match "(\\([0-9][0-9]:[0-9][0-9]\\))$" subject)
1200 (setq date (nnshimbun-make-date-string
1201 year month day (match-string 1 subject))
1202 subject (substring subject 0 (match-beginning 0)))
1203 (setq date (nnshimbun-make-date-string year month day)))
1204 (setcdr (setq x (assoc group group-header-alist))
1205 (cons (make-full-mail-header
1207 (nnshimbun-mime-encode-string subject)
1208 nnshimbun-from-address
1209 date id "" 0 0 (concat nnshimbun-url url))
1211 group-header-alist)))
1217 (defun nnshimbun-zdnet-get-headers ()
1218 (let ((case-fold-search t) headers)
1219 (goto-char (point-min))
1221 (while (and (search-forward "<!--" nil t)
1222 (setq start (- (point) 4))
1223 (search-forward "-->" nil t))
1224 (delete-region start (point))))
1225 (goto-char (point-min))
1226 (while (re-search-forward
1227 "<a href=\"\\(/news/\\)?\\(\\([0-9][0-9]\\)\\([0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([^\\.]+\\).html\\)\"><font size=\"4\"><strong>"
1229 (let ((year (+ 2000 (string-to-number (match-string 3))))
1230 (month (string-to-number (match-string 4)))
1231 (day (string-to-number (match-string 5)))
1232 (id (format "<%s%s%s%s%%%s>"
1237 nnshimbun-current-group))
1238 (url (match-string 2)))
1239 (push (make-full-mail-header
1241 (nnshimbun-mime-encode-string
1242 (mapconcat 'identity
1246 (progn (search-forward "</a>" nil t) (point)))
1249 nnshimbun-from-address
1250 (nnshimbun-make-date-string year month day)
1251 id "" 0 0 (concat nnshimbun-url url))
1253 (nreverse headers)))
1257 ;;; MLs on www.mew.org
1259 (defmacro nnshimbun-mew-concat-url (url)
1260 `(concat nnshimbun-url
1261 (nth 1 (assoc nnshimbun-current-group nnshimbun-mew-groups))
1265 (defmacro nnshimbun-mew-reverse-order-p ()
1266 `(nth 2 (assoc nnshimbun-current-group nnshimbun-mew-groups)))
1268 (defmacro nnshimbun-mew-spew-p ()
1269 `(nth 3 (assoc nnshimbun-current-group nnshimbun-mew-groups)))
1271 (defsubst nnshimbun-mew-retrieve-xover (aux)
1273 (nnshimbun-retrieve-url
1274 (nnshimbun-mew-concat-url (if (= aux 1) "index.html" (format "mail%d.html" aux)))
1277 (defconst nnshimbun-mew-regexp "<A[^>]*HREF=\"\\(msg\\([0-9]+\\).html\\)\">\\([^<]+\\)<")
1279 (defmacro nnshimbun-mew-extract-header-values ()
1281 (setq url (nnshimbun-mew-concat-url (match-string 1))
1282 id (format "<%05d%%%s>"
1283 (1- (string-to-number (match-string 2)))
1284 nnshimbun-current-group)
1285 subject (match-string 3))
1287 (if (nnshimbun-search-id nnshimbun-current-group id)
1288 (throw 'stop headers)
1289 (push (make-full-mail-header
1291 (nnshimbun-mime-encode-string subject)
1292 (if (looking-at "<EM>\\([^<]+\\)<")
1293 (nnshimbun-mime-encode-string (match-string 1))
1299 (if (fboundp 'mime-entity-fetch-field)
1301 (defmacro nnshimbun-mew-mail-header-subject (header)
1302 `(mime-entity-fetch-field ,header 'Subject))
1304 (defalias 'nnshimbun-mew-mail-header-subject 'mail-header-subject)))
1306 (defun nnshimbun-mew-get-headers ()
1307 (if (nnshimbun-mew-spew-p)
1308 (let ((headers (nnshimbun-mew-get-headers-1)))
1310 (insert-buffer-substring (nnshimbun-open-nov nnshimbun-current-group))
1314 (goto-char (point-min))
1315 (let ((subject (nnshimbun-mew-mail-header-subject header))
1317 (while (and (not found)
1318 (search-forward subject nil t))
1319 (if (not (and (search-backward "\t" nil t)
1320 (not (search-backward "\t" (gnus-point-at-bol) t))))
1325 (goto-char (point-max))
1326 (nnheader-insert-nov header)
1329 (nnshimbun-mew-get-headers-1)))
1331 (defun nnshimbun-mew-get-headers-1 ()
1333 (when (re-search-forward
1334 "<A[^>]*HREF=\"mail\\([0-9]+\\)\\.html\">\\[?Last Page\\]?</A>" nil t)
1335 (let ((limit (string-to-number (match-string 1))))
1337 (if (nnshimbun-mew-reverse-order-p)
1339 (while (let (id url subject)
1340 (while (re-search-forward nnshimbun-mew-regexp nil t)
1341 (nnshimbun-mew-extract-header-values))
1343 (nnshimbun-mew-retrieve-xover (setq aux (1+ aux)))))
1345 (nnshimbun-mew-retrieve-xover limit)
1346 (setq limit (1- limit))
1347 (let (id url subject)
1348 (goto-char (point-max))
1349 (while (re-search-backward nnshimbun-mew-regexp nil t)
1350 (nnshimbun-mew-extract-header-values)
1351 (forward-line -2)))))
1356 ;;; MLs on www.xemacs.org
1358 (defmacro nnshimbun-xemacs-concat-url (url)
1359 `(concat nnshimbun-url nnshimbun-current-group "/" ,url))
1361 (defun nnshimbun-xemacs-get-headers ()
1362 (let (headers auxs aux)
1364 (while (re-search-forward
1365 (concat "<A HREF=\"/" nnshimbun-current-group
1366 "/\\([12][0-9][0-9][0-9][0-1][0-9]\\)/\">\\[Index\\]")
1368 (setq auxs (append auxs (list (match-string 1)))))
1371 (nnshimbun-retrieve-url
1372 (nnshimbun-xemacs-concat-url (concat (setq aux (car auxs)) "/")))
1373 (let (id url subject)
1374 (goto-char (point-max))
1375 (while (re-search-backward
1376 "<A[^>]*HREF=\"\\(msg\\([0-9]+\\).html\\)\">\\([^<]+\\)<"
1378 (setq url (nnshimbun-xemacs-concat-url
1379 (concat aux "/" (match-string 1)))
1380 id (format "<%s%05d%%%s>"
1382 (string-to-number (match-string 2))
1383 nnshimbun-current-group)
1384 subject (match-string 3))
1386 (if (nnshimbun-search-id nnshimbun-current-group id)
1387 (throw 'stop headers)
1388 (push (make-full-mail-header
1390 (nnshimbun-mime-encode-string subject)
1391 (if (looking-at "<td><em>\\([^<]+\\)<")
1398 (setq auxs (cdr auxs))))
1401 ;;; MLs on www.jp.netbsd.org
1403 (defun nnshimbun-netbsd-get-headers ()
1404 (let ((case-fold-search t) headers months)
1405 (goto-char (point-min))
1406 (while (re-search-forward "<A HREF=\"\\([0-9]+\\)/\\(threads.html\\)?\">" nil t)
1407 (push (match-string 1) months))
1408 (setq months (nreverse months))
1410 (dolist (month months)
1412 (nnshimbun-retrieve-url
1413 (format "%s%s/%s/maillist.html" nnshimbun-url nnshimbun-current-group month)
1415 (let (id url subject)
1416 (while (re-search-forward
1417 "<A[^>]*HREF=\"\\(msg\\([0-9]+\\)\\.html\\)\">\\([^<]+\\)</A>"
1419 (setq url (format "%s%s/%s/%s"
1421 nnshimbun-current-group
1424 id (format "<%s%05d%%%s>"
1426 (string-to-number (match-string 2))
1427 nnshimbun-current-group)
1428 subject (match-string 3))
1429 (if (nnshimbun-search-id nnshimbun-current-group id)
1430 (throw 'exit headers)
1431 (push (make-full-mail-header
1433 (nnshimbun-mime-encode-string subject)
1434 (if (looking-at "</STRONG> *<EM>\\([^<]+\\)<")
1435 (nnshimbun-mime-encode-string (match-string 1))
1442 (defun nnshimbun-fml-get-headers ()
1443 (let (headers auxs aux)
1445 (while (re-search-forward "<a href=\"\\([0-9]+\\(\\.week\\|\\.month\\)?\\)/index.html\">" nil t)
1446 (setq auxs (append auxs (list (match-string 1)))))
1449 (nnshimbun-retrieve-url
1450 (concat nnshimbun-url (setq aux (car auxs)) "/"))
1451 (subst-char-in-region (point-min) (point-max) ?\t ? t)
1452 (let (id url date subject from)
1453 (goto-char (point-min))
1454 (while (re-search-forward
1455 "<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>"
1457 (setq url (concat nnshimbun-url aux "/" (match-string 1))
1458 id (format "<%s%05d%%%s>"
1460 (string-to-number (match-string 2))
1461 nnshimbun-current-group)
1462 date (match-string 3)
1463 subject (match-string 4)
1464 from (match-string 5))
1466 (if (nnshimbun-search-id nnshimbun-current-group id)
1467 (throw 'stop headers)
1468 (push (make-full-mail-header
1470 (nnshimbun-mime-encode-string subject)
1471 from date id "" 0 0 url)
1475 (setq auxs (cdr auxs))))
1478 (provide 'nnshimbun)
1479 ;;; nnshimbun.el ends here.