1 ;;; nnweb.el --- retrieving articles via web search engines
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs 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)
14 ;; GNU Emacs 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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 ;; Note: You need to have `url' and `w3' installed for this
31 (eval-when-compile (require 'cl))
44 ;; Report failure to find w3 at load time if appropriate.
52 (defvoo nnweb-directory (nnheader-concat gnus-directory "nnweb/")
53 "Where nnweb will save its files.")
55 (defvoo nnweb-type 'dejanews
56 "What search engine type is being used.
57 Valid types include `dejanews', `dejanewsold', `reference',
60 (defvar nnweb-type-definition
63 (id . "http://search.dejanews.com/msgid.xp?MID=%s&fmt=text")
64 (map . nnweb-dejanews-create-mapping)
65 (search . nnweb-dejanews-search)
66 (address . "http://www.deja.com/=dnc/qs.xp")
67 (identifier . nnweb-dejanews-identity))
70 (map . nnweb-dejanews-create-mapping)
71 (search . nnweb-dejanewsold-search)
72 (address . "http://www.deja.com/dnquery.xp")
73 (identifier . nnweb-dejanews-identity))
75 (article . nnweb-reference-wash-article)
76 (map . nnweb-reference-create-mapping)
77 (search . nnweb-reference-search)
78 (address . "http://www.reference.com/cgi-bin/pn/go")
79 (identifier . identity))
81 (article . nnweb-altavista-wash-article)
82 (map . nnweb-altavista-create-mapping)
83 (search . nnweb-altavista-search)
84 (address . "http://www.altavista.digital.com/cgi-bin/query")
85 (id . "/cgi-bin/news?id@%s")
86 (identifier . identity)))
87 "Type-definition alist.")
89 (defvoo nnweb-search nil
90 "Search string to feed to DejaNews.")
92 (defvoo nnweb-max-hits 999
93 "Maximum number of hits to display.")
95 (defvoo nnweb-ephemeral-p nil
96 "Whether this nnweb server is ephemeral.")
98 ;;; Internal variables
100 (defvoo nnweb-articles nil)
101 (defvoo nnweb-buffer nil)
102 (defvoo nnweb-group-alist nil)
103 (defvoo nnweb-group nil)
104 (defvoo nnweb-hashtb nil)
106 ;;; Interface functions
108 (nnoo-define-basics nnweb)
110 (deffoo nnweb-retrieve-headers (articles &optional group server fetch-old)
111 (nnweb-possibly-change-server group server)
113 (set-buffer nntp-server-buffer)
115 (let (article header)
116 (mm-with-unibyte-current-buffer
117 (while (setq article (pop articles))
118 (when (setq header (cadr (assq article nnweb-articles)))
119 (nnheader-insert-nov header))))
122 (deffoo nnweb-request-scan (&optional group server)
123 (nnweb-possibly-change-server group server)
124 (setq nnweb-hashtb (gnus-make-hashtable 4095))
125 (funcall (nnweb-definition 'map))
126 (unless nnweb-ephemeral-p
128 (nnweb-write-overview group)))
130 (deffoo nnweb-request-group (group &optional server dont-check)
131 (nnweb-possibly-change-server nil server)
133 (not (equal group nnweb-group))
134 (not nnweb-ephemeral-p))
135 (let ((info (assoc group nnweb-group-alist)))
137 (setq nnweb-group group)
138 (setq nnweb-type (nth 2 info))
139 (setq nnweb-search (nth 3 info))
141 (nnweb-read-overview group)))))
143 (nnweb-request-scan group))
145 ((not nnweb-articles)
146 (nnheader-report 'nnweb "No matching articles"))
148 (let ((active (if nnweb-ephemeral-p
149 (cons (caar nnweb-articles)
150 (caar (last nnweb-articles)))
151 (cadr (assoc group nnweb-group-alist)))))
152 (nnheader-report 'nnweb "Opened group %s" group)
154 "211 %d %d %d %s\n" (length nnweb-articles)
155 (car active) (cdr active) group)))))
157 (deffoo nnweb-close-group (group &optional server)
158 (nnweb-possibly-change-server group server)
159 (when (gnus-buffer-live-p nnweb-buffer)
161 (set-buffer nnweb-buffer)