Mercurial > emacs
annotate lisp/gnus/gnus-nocem.el @ 40484:2e6c799155b3
(text-mode-map): Remove the \t binding.
(text-mode): Simplify now that the default is more favorable.
(paragraph-indent-text-mode): Fix last change.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 30 Oct 2001 06:00:10 +0000 |
parents | 23d4e36c09fc |
children | 54348dbd8b9c |
rev | line source |
---|---|
17493 | 1 ;;; gnus-nocem.el --- NoCeM pseudo-cancellation treatment |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 |
32599
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
17493 | 4 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 6 ;; Keywords: news |
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 ;;; Code: | |
28 | |
19539
0f90eb270fc7
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
0f90eb270fc7
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'nnmail) | |
33 (require 'gnus-art) | |
34 (require 'gnus-sum) | |
35 (require 'gnus-range) | |
36 | |
37 (defgroup gnus-nocem nil | |
38 "NoCeM pseudo-cancellation treatment" | |
39 :group 'gnus-score) | |
40 | |
41 (defcustom gnus-nocem-groups | |
42 '("news.lists.filters" "news.admin.net-abuse.bulletins" | |
43 "alt.nocem.misc" "news.admin.net-abuse.announce") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
44 "*List of groups that will be searched for NoCeM messages." |
17493 | 45 :group 'gnus-nocem |
46 :type '(repeat (string :tag "Group"))) | |
47 | |
48 (defcustom gnus-nocem-issuers | |
32626 | 49 '("AutoMoose-1" ; CancelMoose[tm] |
50 "clewis@ferret.ocunix" ; Chris Lewis | |
51 "cosmo.roadkill" | |
52 "SpamHippo" | |
53 "hweede@snafu.de") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
54 "*List of NoCeM issuers to pay attention to. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
55 |
32626 | 56 This can also be a list of `(ISSUER CONDITION ...)' elements. |
57 | |
58 See <URL:http://www.xs4all.nl/~rosalind/nocemreg/nocemreg.html> for an | |
59 issuer registry." | |
17493 | 60 :group 'gnus-nocem |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
61 :type '(repeat (choice string sexp))) |
17493 | 62 |
63 (defcustom gnus-nocem-directory | |
64 (nnheader-concat gnus-article-save-directory "NoCeM/") | |
65 "*Directory where NoCeM files will be stored." | |
66 :group 'gnus-nocem | |
67 :type 'directory) | |
68 | |
69 (defcustom gnus-nocem-expiry-wait 15 | |
70 "*Number of days to keep NoCeM headers in the cache." | |
71 :group 'gnus-nocem | |
72 :type 'integer) | |
73 | |
74 (defcustom gnus-nocem-verifyer 'mc-verify | |
75 "*Function called to verify that the NoCeM message is valid. | |
76 One likely value is `mc-verify'. If the function in this variable | |
77 isn't bound, the message will be used unconditionally." | |
78 :group 'gnus-nocem | |
79 :type '(radio (function-item mc-verify) | |
80 (function :tag "other"))) | |
81 | |
82 (defcustom gnus-nocem-liberal-fetch nil | |
83 "*If t try to fetch all messages which have @@NCM in the subject. | |
84 Otherwise don't fetch messages which have references or whose message-id | |
85 matches an previously scanned and verified nocem message." | |
86 :group 'gnus-nocem | |
87 :type 'boolean) | |
88 | |
33178
23d4e36c09fc
(gnus-nocem-check-article-limit): Default to 500.
Dave Love <fx@gnu.org>
parents:
32626
diff
changeset
|
89 (defcustom gnus-nocem-check-article-limit 500 |
32599
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
90 "*If non-nil, the maximum number of articles to check in any NoCeM group." |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
91 :group 'gnus-nocem |
32626 | 92 :version "21.1" |
32599
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
93 :type '(choice (const :tag "unlimited" nil) |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
94 (integer 1000))) |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
95 |
32626 | 96 (defcustom gnus-nocem-check-from t |
97 "Non-nil means check for valid issuers in message bodies. | |
98 Otherwise don't bother fetching articles unless their author matches a | |
99 valid issuer, which is much faster if you are selective about the issuers." | |
100 :group 'gnus-nocem | |
101 :version "21.1" | |
102 :type 'boolean) | |
103 | |
17493 | 104 ;;; Internal variables |
105 | |
106 (defvar gnus-nocem-active nil) | |
107 (defvar gnus-nocem-alist nil) | |
108 (defvar gnus-nocem-touched-alist nil) | |
109 (defvar gnus-nocem-hashtb nil) | |
110 (defvar gnus-nocem-seen-message-ids nil) | |
111 | |
112 ;;; Functions | |
113 | |
114 (defun gnus-nocem-active-file () | |
115 (concat (file-name-as-directory gnus-nocem-directory) "active")) | |
116 | |
117 (defun gnus-nocem-cache-file () | |
118 (concat (file-name-as-directory gnus-nocem-directory) "cache")) | |
119 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
120 ;; |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
121 ;; faster lookups for group names: |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
122 ;; |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
123 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
124 (defvar gnus-nocem-real-group-hashtb nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
125 "Real-name mappings of subscribed groups.") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
126 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
127 (defun gnus-fill-real-hashtb () |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
128 "Fill up a hash table with the real-name mappings from the user's active file." |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
129 (setq gnus-nocem-real-group-hashtb (gnus-make-hashtable |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
130 (length gnus-newsrc-alist))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
131 (mapcar (lambda (group) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
132 (setq group (gnus-group-real-name (car group))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
133 (gnus-sethash group t gnus-nocem-real-group-hashtb)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
134 gnus-newsrc-alist)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
135 |
17493 | 136 (defun gnus-nocem-scan-groups () |
137 "Scan all NoCeM groups for new NoCeM messages." | |
138 (interactive) | |
139 (let ((groups gnus-nocem-groups) | |
140 (gnus-inhibit-demon t) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
141 group active gactive articles check-headers) |
17493 | 142 (gnus-make-directory gnus-nocem-directory) |
143 ;; Load any previous NoCeM headers. | |
144 (gnus-nocem-load-cache) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
145 ;; Get the group name mappings: |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
146 (gnus-fill-real-hashtb) |
17493 | 147 ;; Read the active file if it hasn't been read yet. |
148 (and (file-exists-p (gnus-nocem-active-file)) | |
149 (not gnus-nocem-active) | |
150 (ignore-errors | |
151 (load (gnus-nocem-active-file) t t t))) | |
152 ;; Go through all groups and see whether new articles have | |
153 ;; arrived. | |
154 (while (setq group (pop groups)) | |
155 (if (not (setq gactive (gnus-activate-group group))) | |
156 () ; This group doesn't exist. | |
157 (setq active (nth 1 (assoc group gnus-nocem-active))) | |
158 (when (and (not (< (cdr gactive) (car gactive))) ; Empty group. | |
159 (or (not active) | |
160 (< (cdr active) (cdr gactive)))) | |
161 ;; Ok, there are new articles in this group, se we fetch the | |
162 ;; headers. | |
163 (save-excursion | |
164 (let ((dependencies (make-vector 10 nil)) | |
165 headers header) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
166 (with-temp-buffer |
17493 | 167 (setq headers |
168 (if (eq 'nov | |
169 (gnus-retrieve-headers | |
170 (setq articles | |
171 (gnus-uncompress-range | |
172 (cons | |
173 (if active (1+ (cdr active)) | |
174 (car gactive)) | |
175 (cdr gactive)))) | |
176 group)) | |
177 (gnus-get-newsgroup-headers-xover | |
178 articles nil dependencies) | |
179 (gnus-get-newsgroup-headers dependencies))) | |
180 (while (setq header (pop headers)) | |
181 ;; We take a closer look on all articles that have | |
182 ;; "@@NCM" in the subject. Unless we already read | |
183 ;; this cross posted message. Nocem messages | |
184 ;; are not allowed to have references, so we can | |
185 ;; ignore scanning followups. | |
186 (and (string-match "@@NCM" (mail-header-subject header)) | |
32626 | 187 (and gnus-nocem-check-from |
188 (let ((case-fold-search t)) | |
189 (catch 'ok | |
190 (mapcar | |
191 (lambda (author) | |
192 (if (consp author) | |
193 (setq author (car author))) | |
194 (if (string-match | |
195 author (mail-header-from header)) | |
196 (throw 'ok t))) | |
197 gnus-nocem-issuers) | |
198 nil))) | |
17493 | 199 (or gnus-nocem-liberal-fetch |
200 (and (or (string= "" (mail-header-references | |
201 header)) | |
202 (null (mail-header-references header))) | |
203 (not (member (mail-header-message-id header) | |
204 gnus-nocem-seen-message-ids)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
205 (push header check-headers))) |
32599
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
206 (let* ((i 0) |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
207 (check-headers |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
208 (last check-headers gnus-nocem-check-article-limit)) |
0db9e380f3ec
(gnus-nocem-check-article-limit): New variable.
Miles Bader <miles@gnu.org>
parents:
31716
diff
changeset
|
209 (len (length check-headers))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
210 (dolist (h check-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
211 (gnus-message |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
212 7 "Checking article %d in %s for NoCeM (%d of %d)..." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
213 (mail-header-number h) group (incf i) len) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
214 (gnus-nocem-check-article group h))))))) |
17493 | 215 (setq gnus-nocem-active |
216 (cons (list group gactive) | |
217 (delq (assoc group gnus-nocem-active) | |
218 gnus-nocem-active))))) | |
219 ;; Save the results, if any. | |
220 (gnus-nocem-save-cache) | |
221 (gnus-nocem-save-active))) | |
222 | |
223 (defun gnus-nocem-check-article (group header) | |
224 "Check whether the current article is an NCM article and that we want it." | |
225 ;; Get the article. | |
226 (let ((date (mail-header-date header)) | |
32626 | 227 (gnus-newsgroup-name group) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
228 issuer b e type) |
17493 | 229 (when (or (not date) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
230 (time-less-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
231 (time-since (date-to-time date)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
232 (days-to-time gnus-nocem-expiry-wait))) |
17493 | 233 (gnus-request-article-this-buffer (mail-header-number header) group) |
234 (goto-char (point-min)) | |
235 (when (re-search-forward "-----BEGIN PGP MESSAGE-----" nil t) | |
236 (delete-region (point-min) (match-beginning 0))) | |
237 (when (re-search-forward "-----END PGP MESSAGE-----\n?" nil t) | |
238 (delete-region (match-end 0) (point-max))) | |
239 (goto-char (point-min)) | |
240 ;; The article has to have proper NoCeM headers. | |
241 (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t)) | |
242 (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t))) | |
243 ;; We get the name of the issuer. | |
244 (narrow-to-region b e) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
245 (setq issuer (mail-fetch-field "issuer") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
246 type (mail-fetch-field "issuer")) |
17493 | 247 (widen) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
248 (if (not (gnus-nocem-message-wanted-p issuer type)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
249 (message "invalid NoCeM issuer: %s" issuer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
250 (and (gnus-nocem-verify-issuer issuer) ; She is who she says she is. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
251 (gnus-nocem-enter-article) ; We gobble the message. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
252 (push (mail-header-message-id header) ; But don't come back for |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
253 gnus-nocem-seen-message-ids))))))) ; second helpings. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
254 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
255 (defun gnus-nocem-message-wanted-p (issuer type) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
256 (let ((issuers gnus-nocem-issuers) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
257 wanted conditions condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
258 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
259 ;; Do the quick check first. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
260 ((member issuer issuers) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
261 t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
262 ((setq conditions (cdr (assoc issuer issuers))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
263 ;; Check whether we want this type. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
264 (while (setq condition (pop conditions)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
265 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
266 ((stringp condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
267 (setq wanted (string-match condition type))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
268 ((and (consp condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
269 (eq (car condition) 'not) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
270 (stringp (cadr condition))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
271 (setq wanted (not (string-match (cadr condition) type)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
272 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
273 (error "Invalid NoCeM condition: %S" condition)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
274 wanted)))) |
17493 | 275 |
276 (defun gnus-nocem-verify-issuer (person) | |
277 "Verify using PGP that the canceler is who she says she is." | |
278 (if (fboundp gnus-nocem-verifyer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
279 (ignore-errors |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
280 (funcall gnus-nocem-verifyer)) |
17493 | 281 ;; If we don't have Mailcrypt, then we use the message anyway. |
282 t)) | |
283 | |
284 (defun gnus-nocem-enter-article () | |
285 "Enter the current article into the NoCeM cache." | |
286 (goto-char (point-min)) | |
287 (let ((b (search-forward "\n@@BEGIN NCM BODY\n" nil t)) | |
288 (e (search-forward "\n@@END NCM BODY\n" nil t)) | |
289 (buf (current-buffer)) | |
290 ncm id group) | |
291 (when (and b e) | |
292 (narrow-to-region b (1+ (match-beginning 0))) | |
293 (goto-char (point-min)) | |
294 (while (search-forward "\t" nil t) | |
295 (cond | |
296 ((not (ignore-errors | |
297 (setq group (let ((obarray gnus-active-hashtb)) (read buf))))) | |
298 ;; An error. | |
299 ) | |
300 ((not (symbolp group)) | |
301 ;; Ignore invalid entries. | |
302 ) | |
303 ((not (boundp group)) | |
304 ;; Make sure all entries in the hashtb are bound. | |
305 (set group nil)) | |
306 (t | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
307 (when (gnus-gethash (gnus-group-real-name (symbol-name group)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
308 gnus-nocem-real-group-hashtb) |
17493 | 309 ;; Valid group. |
310 (beginning-of-line) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
311 (while (eq (char-after) ?\t) |
17493 | 312 (forward-line -1)) |
313 (setq id (buffer-substring (point) (1- (search-forward "\t")))) | |
314 (unless (gnus-gethash id gnus-nocem-hashtb) | |
315 ;; only store if not already present | |
316 (gnus-sethash id t gnus-nocem-hashtb) | |
317 (push id ncm)) | |
318 (forward-line 1) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
319 (while (eq (char-after) ?\t) |
17493 | 320 (forward-line 1)))))) |
321 (when ncm | |
322 (setq gnus-nocem-touched-alist t) | |
323 (push (cons (let ((time (current-time))) (setcdr (cdr time) nil) time) | |
324 ncm) | |
325 gnus-nocem-alist)) | |
326 t))) | |
327 | |
328 (defun gnus-nocem-load-cache () | |
329 "Load the NoCeM cache." | |
330 (interactive) | |
331 (unless gnus-nocem-alist | |
332 ;; The buffer doesn't exist, so we create it and load the NoCeM | |
333 ;; cache. | |
334 (when (file-exists-p (gnus-nocem-cache-file)) | |
335 (load (gnus-nocem-cache-file) t t t) | |
336 (gnus-nocem-alist-to-hashtb)))) | |
337 | |
338 (defun gnus-nocem-save-cache () | |
339 "Save the NoCeM cache." | |
340 (when (and gnus-nocem-alist | |
341 gnus-nocem-touched-alist) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
342 (with-temp-file (gnus-nocem-cache-file) |
17493 | 343 (gnus-prin1 `(setq gnus-nocem-alist ',gnus-nocem-alist))) |
344 (setq gnus-nocem-touched-alist nil))) | |
345 | |
346 (defun gnus-nocem-save-active () | |
347 "Save the NoCeM active file." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
348 (with-temp-file (gnus-nocem-active-file) |
17493 | 349 (gnus-prin1 `(setq gnus-nocem-active ',gnus-nocem-active)))) |
350 | |
351 (defun gnus-nocem-alist-to-hashtb () | |
352 "Create a hashtable from the Message-IDs we have." | |
353 (let* ((alist gnus-nocem-alist) | |
354 (pprev (cons nil alist)) | |
355 (prev pprev) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
356 (expiry (days-to-time gnus-nocem-expiry-wait)) |
17493 | 357 entry) |
358 (setq gnus-nocem-hashtb (gnus-make-hashtable (* (length alist) 51))) | |
359 (while (setq entry (car alist)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
360 (if (not (time-less-p (time-since (car entry)) expiry)) |
17493 | 361 ;; This entry has expired, so we remove it. |
362 (setcdr prev (cdr alist)) | |
363 (setq prev alist) | |
364 ;; This is ok, so we enter it into the hashtable. | |
365 (setq entry (cdr entry)) | |
366 (while entry | |
367 (gnus-sethash (car entry) t gnus-nocem-hashtb) | |
368 (setq entry (cdr entry)))) | |
369 (setq alist (cdr alist))))) | |
370 | |
371 (gnus-add-shutdown 'gnus-nocem-close 'gnus) | |
372 | |
373 (defun gnus-nocem-close () | |
374 "Clear internal NoCeM variables." | |
375 (setq gnus-nocem-alist nil | |
376 gnus-nocem-hashtb nil | |
377 gnus-nocem-active nil | |
378 gnus-nocem-touched-alist nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
379 gnus-nocem-seen-message-ids nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
380 gnus-nocem-real-group-hashtb nil)) |
17493 | 381 |
382 (defun gnus-nocem-unwanted-article-p (id) | |
383 "Say whether article ID in the current group is wanted." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
384 (and gnus-nocem-hashtb |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
385 (gnus-gethash id gnus-nocem-hashtb))) |
17493 | 386 |
387 (provide 'gnus-nocem) | |
388 | |
389 ;;; gnus-nocem.el ends here |