Mercurial > emacs
annotate lisp/gnus/nnlistserv.el @ 53201:c90162ba57c6
(Fget_char_property_and_overlay): New function.
(syms_of_textprop): Defsubr it.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Sun, 30 Nov 2003 17:08:28 +0000 |
parents | 695cf19ef79e |
children | cb0bc8ce8e5a 375f2633d815 |
rev | line source |
---|---|
24358 | 1 ;;; nnlistserv.el --- retrieving articles via web mailing list archives |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
2 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
3 ;; Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
24358 | 4 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
6 ;; Keywords: news, mail | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; Note: You need to have `url' and `w3' installed for this | |
28 ;; backend to work. | |
29 | |
30 ;;; Code: | |
31 | |
32 (eval-when-compile (require 'cl)) | |
33 | |
34 (require 'nnoo) | |
33924
c8c683f24c57
Ignore errors when requiring nnweb and avoid a
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
35 (eval-when-compile |
c8c683f24c57
Ignore errors when requiring nnweb and avoid a
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
36 (ignore-errors |
c8c683f24c57
Ignore errors when requiring nnweb and avoid a
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
37 (require 'nnweb)) ; requires W3 |
c8c683f24c57
Ignore errors when requiring nnweb and avoid a
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
38 (autoload 'url-insert-file-contents "nnweb")) |
24358 | 39 |
40 (nnoo-declare nnlistserv | |
41 nnweb) | |
42 | |
43 (defvoo nnlistserv-directory (nnheader-concat gnus-directory "nnlistserv/") | |
44 "Where nnlistserv will save its files." | |
45 nnweb-directory) | |
46 | |
47 (defvoo nnlistserv-name 'kk | |
48 "What search engine type is being used." | |
49 nnweb-type) | |
50 | |
51 (defvoo nnlistserv-type-definition | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
52 '((kk |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
53 (article . nnlistserv-kk-wash-article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
54 (map . nnlistserv-kk-create-mapping) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
55 (search . nnlistserv-kk-search) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
56 (address . "http://www.itk.ntnu.no/ansatte/Andresen_Trond/kk-f/%s/") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
57 (pages "fra160396" "fra160796" "fra061196" "fra160197" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
58 "fra090997" "fra040797" "fra130397" "nye") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
59 (index . "date.html") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
60 (identifier . nnlistserv-kk-identity))) |
24358 | 61 "Type-definition alist." |
62 nnweb-type-definition) | |
63 | |
64 (defvoo nnlistserv-search nil | |
65 "Search string to feed to DejaNews." | |
66 nnweb-search) | |
67 | |
68 (defvoo nnlistserv-ephemeral-p nil | |
69 "Whether this nnlistserv server is ephemeral." | |
70 nnweb-ephemeral-p) | |
71 | |
72 ;;; Internal variables | |
73 | |
74 ;;; Interface functions | |
75 | |
76 (nnoo-define-basics nnlistserv) | |
77 | |
78 (nnoo-import nnlistserv | |
79 (nnweb)) | |
80 | |
81 ;;; Internal functions | |
82 | |
83 ;;; | |
84 ;;; KK functions. | |
85 ;;; | |
86 | |
87 (defun nnlistserv-kk-create-mapping () | |
47935
70d7c96ed22f
(nnlistserv-kk-create-mapping): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
33924
diff
changeset
|
88 "Perform the search and create a number-to-url alist." |
24358 | 89 (save-excursion |
90 (set-buffer nnweb-buffer) | |
91 (let ((case-fold-search t) | |
92 (active (or (cadr (assoc nnweb-group nnweb-group-alist)) | |
93 (cons 1 0))) | |
94 (pages (nnweb-definition 'pages)) | |
95 map url page subject from ) | |
96 (while (setq page (pop pages)) | |
97 (erase-buffer) | |
98 (when (funcall (nnweb-definition 'search) page) | |
99 ;; Go through all the article hits on this page. | |
100 (goto-char (point-min)) | |
101 (nnweb-decode-entities) | |
102 (goto-char (point-min)) | |
103 (while (re-search-forward "^<li> *<a href=\"\\([^\"]+\\)\"><b>\\([^\\>]+\\)</b></a> *<[^>]+><i>\\([^>]+\\)<" nil t) | |
104 (setq url (match-string 1) | |
105 subject (match-string 2) | |
106 from (match-string 3)) | |
107 (setq url (concat (format (nnweb-definition 'address) page) url)) | |
108 (unless (nnweb-get-hashtb url) | |
109 (push | |
110 (list | |
111 (incf (cdr active)) | |
112 (make-full-mail-header | |
113 (cdr active) subject from "" | |
114 (concat "<" (nnweb-identifier url) "@kk>") | |
115 nil 0 0 url)) | |
116 map) | |
117 (nnweb-set-hashtb (cadar map) (car map)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
118 (nnheader-message 5 "%s %s %s" (cdr active) (point) pages))))) |
24358 | 119 ;; Return the articles in the right order. |
120 (setq nnweb-articles | |
121 (sort (nconc nnweb-articles map) 'car-less-than-car))))) | |
122 | |
123 (defun nnlistserv-kk-wash-article () | |
124 (let ((case-fold-search t) | |
125 (headers '(sent name email subject id)) | |
126 sent name email subject id) | |
127 (nnweb-decode-entities) | |
128 (while headers | |
129 (goto-char (point-min)) | |
130 (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers) nil t)) | |
131 (set (pop headers) (match-string 1))) | |
132 (goto-char (point-min)) | |
133 (search-forward "<!-- body" nil t) | |
134 (delete-region (point-min) (progn (forward-line 1) (point))) | |
135 (goto-char (point-max)) | |
136 (search-backward "<!-- body" nil t) | |
137 (delete-region (point-max) (progn (beginning-of-line) (point))) | |
138 (nnweb-remove-markup) | |
139 (goto-char (point-min)) | |
140 (insert (format "From: %s <%s>\n" name email) | |
141 (format "Subject: %s\n" subject) | |
142 (format "Message-ID: %s\n" id) | |
143 (format "Date: %s\n\n" sent)))) | |
144 | |
145 (defun nnlistserv-kk-search (search) | |
146 (url-insert-file-contents | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24577
diff
changeset
|
147 (concat (format (nnweb-definition 'address) search) |
24358 | 148 (nnweb-definition 'index))) |
149 t) | |
150 | |
151 (defun nnlistserv-kk-identity (url) | |
152 "Return an unique identifier based on URL." | |
153 url) | |
154 | |
155 (provide 'nnlistserv) | |
156 | |
52401 | 157 ;;; arch-tag: 7705176f-d332-4a5e-a520-d0d319445617 |
24358 | 158 ;;; nnlistserv.el ends here |