annotate lisp/gnus/gnus-nocem.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gnus-nocem.el --- NoCeM pseudo-cancellation treatment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'nnmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar gnus-nocem-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 '("alt.nocem.misc" "news.admin.net-abuse.announce")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 "*List of groups that will be searched for NoCeM messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defvar gnus-nocem-issuers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 '("Automoose-1" ; The CancelMoose[tm] on autopilot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "clewis@ferret.ocunix.on.ca;" ; Chris Lewis -- Canadian angel & despammer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "jem@xpat.com;" ; John Milburn -- despammer in Korea.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "red@redpoll.mrfs.oh.us (Richard E. Depew)" ; Spew/bincancel guy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*List of NoCeM issuers to pay attention to.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar gnus-nocem-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (concat (file-name-as-directory gnus-article-save-directory) "NoCeM/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*Directory where NoCeM files will be stored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar gnus-nocem-expiry-wait 15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 "*Number of days to keep NoCeM headers in the cache.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar gnus-nocem-verifyer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "*Function called to verify that the NoCeM message is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 One likely value is `mc-verify'. If the function in this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 isn't bound, the message will be used unconditionally.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar gnus-nocem-active nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar gnus-nocem-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defvar gnus-nocem-touched-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar gnus-nocem-hashtb nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun gnus-nocem-active-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (concat (file-name-as-directory gnus-nocem-directory) "active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun gnus-nocem-cache-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (concat (file-name-as-directory gnus-nocem-directory) "cache"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun gnus-nocem-scan-groups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Scan all NoCeM groups for new NoCeM messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let ((groups gnus-nocem-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 group active gactive articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (or (file-exists-p gnus-nocem-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (make-directory gnus-nocem-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; Load any previous NoCeM headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (gnus-nocem-load-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; Read the active file if it hasn't been read yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (and (file-exists-p (gnus-nocem-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (not gnus-nocem-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (load (gnus-nocem-active-file) t t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Go through all groups and see whether new articles have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; arrived.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (while (setq group (pop groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (not (setq gactive (gnus-activate-group group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 () ; This group doesn't exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq active (nth 1 (assoc group gnus-nocem-active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (when (and (not (< (cdr gactive) (car gactive))) ; Empty group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (or (not active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (< (cdr active) (cdr gactive))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Ok, there are new articles in this group, se we fetch the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let ((dependencies (make-vector 10 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (buffer (nnheader-set-temp-buffer " *Gnus NoCeM*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (eq 'nov
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (gnus-retrieve-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (gnus-uncompress-range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if active (1+ (cdr active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (car gactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cdr gactive))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (gnus-get-newsgroup-headers-xover
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 articles nil dependencies)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (gnus-get-newsgroup-headers dependencies)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (while headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; We take a closer look on all articles that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; "@@NCM" in the subject.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (when (string-match "@@NCM"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (mail-header-subject (car headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (gnus-nocem-check-article group (car headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq headers (cdr headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq gnus-nocem-active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (cons (list group gactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (delq (assoc group gnus-nocem-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 gnus-nocem-active)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; Save the results, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (gnus-nocem-save-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (gnus-nocem-save-active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun gnus-nocem-check-article (group header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Check whether the current article is an NCM article and that we want it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; Get the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (gnus-message 7 "Checking article %d in %s for NoCeM..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (mail-header-number header) group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((date (mail-header-date header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 issuer b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (when (or (not date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (nnmail-time-less
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (nnmail-time-since (nnmail-date-to-time date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (nnmail-days-to-time gnus-nocem-expiry-wait)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (gnus-request-article-this-buffer (mail-header-number header) group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; The article has to have proper NoCeM headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; We get the name of the issuer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (narrow-to-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq issuer (mail-fetch-field "issuer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (and (member issuer gnus-nocem-issuers) ; We like her...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (gnus-nocem-verify-issuer issuer) ; She is who she says she is..
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (gnus-nocem-enter-article)))))) ; We gobble the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defun gnus-nocem-verify-issuer (person)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Verify using PGP that the canceler is who she says she is."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (fboundp gnus-nocem-verifyer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (funcall gnus-nocem-verifyer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; If we don't have MailCrypt, then we use the message anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun gnus-nocem-enter-article ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "Enter the current article into the NoCeM cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (let ((b (search-forward "\n@@BEGIN NCM BODY\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (e (search-forward "\n@@END NCM BODY\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ncm id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (when (and b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (narrow-to-region b (1+ (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (while (search-forward "\t" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (when (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (boundp (let ((obarray gnus-active-hashtb)) (read buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (while (= (following-char) ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (setq id (buffer-substring (point) (1- (search-forward "\t"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (push id ncm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (gnus-sethash id t gnus-nocem-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (while (= (following-char) ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (when ncm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq gnus-nocem-touched-alist t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (push (cons (let ((time (current-time))) (setcdr (cdr time) nil) time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ncm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 gnus-nocem-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun gnus-nocem-load-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Load the NoCeM cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (unless gnus-nocem-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; The buffer doesn't exist, so we create it and load the NoCeM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (when (file-exists-p (gnus-nocem-cache-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (load (gnus-nocem-cache-file) t t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (gnus-nocem-alist-to-hashtb))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun gnus-nocem-save-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "Save the NoCeM cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (when (and gnus-nocem-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 gnus-nocem-touched-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (nnheader-temp-write (gnus-nocem-cache-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (prin1 `(setq gnus-nocem-alist ',gnus-nocem-alist) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq gnus-nocem-touched-alist nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defun gnus-nocem-save-active ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "Save the NoCeM active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (nnheader-temp-write (gnus-nocem-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (prin1 `(setq gnus-nocem-active ',gnus-nocem-active) (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defun gnus-nocem-alist-to-hashtb ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Create a hashtable from the Message-IDs we have."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (let* ((alist gnus-nocem-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (pprev (cons nil alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (prev pprev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (expiry (nnmail-days-to-time gnus-nocem-expiry-wait))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq gnus-nocem-hashtb (gnus-make-hashtable (* (length alist) 51)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (while (setq entry (car alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if (not (nnmail-time-less (nnmail-time-since (car entry)) expiry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; This entry has expired, so we remove it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setcdr prev (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (setq prev alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; This is ok, so we enter it into the hashtable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq entry (cdr entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (while entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (gnus-sethash (car entry) t gnus-nocem-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq entry (cdr entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (gnus-add-shutdown 'gnus-nocem-close 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defun gnus-nocem-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "Clear internal NoCeM variables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq gnus-nocem-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 gnus-nocem-hashtb nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 gnus-nocem-active nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 gnus-nocem-touched-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun gnus-nocem-unwanted-article-p (id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Say whether article ID in the current group is wanted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (gnus-gethash id gnus-nocem-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (provide 'gnus-nocem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; gnus-nocem.el ends here