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