Mercurial > emacs
annotate lisp/gnus/gnus-nocem.el @ 31806:b148beb59511
(process_sent_to): New variable.
(send_process): Workaround for a crash on sparc-sun-solaris-2.6
with GCC 2.95.2 caused by a parameter being clobbered by longjmp.
Declare more parameters volatile.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 21 Sep 2000 11:48:48 +0000 |
parents | 9968f55ad26e |
children | 0db9e380f3ec |
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 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999 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 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
49 '("AutoMoose-1" "Automoose-1" ; CancelMoose[tm] |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
50 "rbraver@ohww.norman.ok.us" ; Robert Braver |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
51 "clewis@ferret.ocunix.on.ca" ; Chris Lewis |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
52 "jem@xpat.com" ; Despammer from Korea |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
53 "snowhare@xmission.com" ; Benjamin "Snowhare" Franz |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 "red@redpoll.mrfs.oh.us (Richard E. Depew)") ; ARMM! ARMM! |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
55 "*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
|
56 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
57 This can also be a list of `(ISSUER CONDITIONS)' elements." |
17493 | 58 :group 'gnus-nocem |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
59 :type '(repeat (choice string sexp))) |
17493 | 60 |
61 (defcustom gnus-nocem-directory | |
62 (nnheader-concat gnus-article-save-directory "NoCeM/") | |
63 "*Directory where NoCeM files will be stored." | |
64 :group 'gnus-nocem | |
65 :type 'directory) | |
66 | |
67 (defcustom gnus-nocem-expiry-wait 15 | |
68 "*Number of days to keep NoCeM headers in the cache." | |
69 :group 'gnus-nocem | |
70 :type 'integer) | |
71 | |
72 (defcustom gnus-nocem-verifyer 'mc-verify | |
73 "*Function called to verify that the NoCeM message is valid. | |
74 One likely value is `mc-verify'. If the function in this variable | |
75 isn't bound, the message will be used unconditionally." | |
76 :group 'gnus-nocem | |
77 :type '(radio (function-item mc-verify) | |
78 (function :tag "other"))) | |
79 | |
80 (defcustom gnus-nocem-liberal-fetch nil | |
81 "*If t try to fetch all messages which have @@NCM in the subject. | |
82 Otherwise don't fetch messages which have references or whose message-id | |
83 matches an previously scanned and verified nocem message." | |
84 :group 'gnus-nocem | |
85 :type 'boolean) | |
86 | |
87 ;;; Internal variables | |
88 | |
89 (defvar gnus-nocem-active nil) | |
90 (defvar gnus-nocem-alist nil) | |
91 (defvar gnus-nocem-touched-alist nil) | |
92 (defvar gnus-nocem-hashtb nil) | |
93 (defvar gnus-nocem-seen-message-ids nil) | |
94 | |
95 ;;; Functions | |
96 | |
97 (defun gnus-nocem-active-file () | |
98 (concat (file-name-as-directory gnus-nocem-directory) "active")) | |
99 | |
100 (defun gnus-nocem-cache-file () | |
101 (concat (file-name-as-directory gnus-nocem-directory) "cache")) | |
102 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
103 ;; |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
104 ;; faster lookups for group names: |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
105 ;; |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
106 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
107 (defvar gnus-nocem-real-group-hashtb nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
108 "Real-name mappings of subscribed groups.") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
109 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
110 (defun gnus-fill-real-hashtb () |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
111 "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
|
112 (setq gnus-nocem-real-group-hashtb (gnus-make-hashtable |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
113 (length gnus-newsrc-alist))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
114 (mapcar (lambda (group) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
115 (setq group (gnus-group-real-name (car group))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
116 (gnus-sethash group t gnus-nocem-real-group-hashtb)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
117 gnus-newsrc-alist)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
118 |
17493 | 119 (defun gnus-nocem-scan-groups () |
120 "Scan all NoCeM groups for new NoCeM messages." | |
121 (interactive) | |
122 (let ((groups gnus-nocem-groups) | |
123 (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
|
124 group active gactive articles check-headers) |
17493 | 125 (gnus-make-directory gnus-nocem-directory) |
126 ;; Load any previous NoCeM headers. | |
127 (gnus-nocem-load-cache) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
128 ;; Get the group name mappings: |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
129 (gnus-fill-real-hashtb) |
17493 | 130 ;; Read the active file if it hasn't been read yet. |
131 (and (file-exists-p (gnus-nocem-active-file)) | |
132 (not gnus-nocem-active) | |
133 (ignore-errors | |
134 (load (gnus-nocem-active-file) t t t))) | |
135 ;; Go through all groups and see whether new articles have | |
136 ;; arrived. | |
137 (while (setq group (pop groups)) | |
138 (if (not (setq gactive (gnus-activate-group group))) | |
139 () ; This group doesn't exist. | |
140 (setq active (nth 1 (assoc group gnus-nocem-active))) | |
141 (when (and (not (< (cdr gactive) (car gactive))) ; Empty group. | |
142 (or (not active) | |
143 (< (cdr active) (cdr gactive)))) | |
144 ;; Ok, there are new articles in this group, se we fetch the | |
145 ;; headers. | |
146 (save-excursion | |
147 (let ((dependencies (make-vector 10 nil)) | |
148 headers header) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
149 (with-temp-buffer |
17493 | 150 (setq headers |
151 (if (eq 'nov | |
152 (gnus-retrieve-headers | |
153 (setq articles | |
154 (gnus-uncompress-range | |
155 (cons | |
156 (if active (1+ (cdr active)) | |
157 (car gactive)) | |
158 (cdr gactive)))) | |
159 group)) | |
160 (gnus-get-newsgroup-headers-xover | |
161 articles nil dependencies) | |
162 (gnus-get-newsgroup-headers dependencies))) | |
163 (while (setq header (pop headers)) | |
164 ;; We take a closer look on all articles that have | |
165 ;; "@@NCM" in the subject. Unless we already read | |
166 ;; this cross posted message. Nocem messages | |
167 ;; are not allowed to have references, so we can | |
168 ;; ignore scanning followups. | |
169 (and (string-match "@@NCM" (mail-header-subject header)) | |
170 (or gnus-nocem-liberal-fetch | |
171 (and (or (string= "" (mail-header-references | |
172 header)) | |
173 (null (mail-header-references header))) | |
174 (not (member (mail-header-message-id header) | |
175 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
|
176 (push header check-headers))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
177 (let ((i 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
178 (len (length check-headers))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
179 (dolist (h check-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
180 (gnus-message |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
181 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
|
182 (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
|
183 (gnus-nocem-check-article group h))))))) |
17493 | 184 (setq gnus-nocem-active |
185 (cons (list group gactive) | |
186 (delq (assoc group gnus-nocem-active) | |
187 gnus-nocem-active))))) | |
188 ;; Save the results, if any. | |
189 (gnus-nocem-save-cache) | |
190 (gnus-nocem-save-active))) | |
191 | |
192 (defun gnus-nocem-check-article (group header) | |
193 "Check whether the current article is an NCM article and that we want it." | |
194 ;; Get the article. | |
195 (let ((date (mail-header-date header)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
196 issuer b e type) |
17493 | 197 (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
|
198 (time-less-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
199 (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
|
200 (days-to-time gnus-nocem-expiry-wait))) |
17493 | 201 (gnus-request-article-this-buffer (mail-header-number header) group) |
202 (goto-char (point-min)) | |
203 (when (re-search-forward "-----BEGIN PGP MESSAGE-----" nil t) | |
204 (delete-region (point-min) (match-beginning 0))) | |
205 (when (re-search-forward "-----END PGP MESSAGE-----\n?" nil t) | |
206 (delete-region (match-end 0) (point-max))) | |
207 (goto-char (point-min)) | |
208 ;; The article has to have proper NoCeM headers. | |
209 (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t)) | |
210 (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t))) | |
211 ;; We get the name of the issuer. | |
212 (narrow-to-region b e) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
213 (setq issuer (mail-fetch-field "issuer") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
214 type (mail-fetch-field "issuer")) |
17493 | 215 (widen) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
216 (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
|
217 (message "invalid NoCeM issuer: %s" issuer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
218 (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
|
219 (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
|
220 (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
|
221 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
|
222 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
223 (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
|
224 (let ((issuers gnus-nocem-issuers) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
225 wanted conditions condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
226 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
227 ;; Do the quick check first. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
228 ((member issuer issuers) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
229 t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
230 ((setq conditions (cdr (assoc issuer issuers))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
231 ;; Check whether we want this type. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
232 (while (setq condition (pop conditions)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
233 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
234 ((stringp condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
235 (setq wanted (string-match condition type))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
236 ((and (consp condition) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
237 (eq (car condition) 'not) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
238 (stringp (cadr condition))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
239 (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
|
240 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
241 (error "Invalid NoCeM condition: %S" condition)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
242 wanted)))) |
17493 | 243 |
244 (defun gnus-nocem-verify-issuer (person) | |
245 "Verify using PGP that the canceler is who she says she is." | |
246 (if (fboundp gnus-nocem-verifyer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
247 (ignore-errors |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
248 (funcall gnus-nocem-verifyer)) |
17493 | 249 ;; If we don't have Mailcrypt, then we use the message anyway. |
250 t)) | |
251 | |
252 (defun gnus-nocem-enter-article () | |
253 "Enter the current article into the NoCeM cache." | |
254 (goto-char (point-min)) | |
255 (let ((b (search-forward "\n@@BEGIN NCM BODY\n" nil t)) | |
256 (e (search-forward "\n@@END NCM BODY\n" nil t)) | |
257 (buf (current-buffer)) | |
258 ncm id group) | |
259 (when (and b e) | |
260 (narrow-to-region b (1+ (match-beginning 0))) | |
261 (goto-char (point-min)) | |
262 (while (search-forward "\t" nil t) | |
263 (cond | |
264 ((not (ignore-errors | |
265 (setq group (let ((obarray gnus-active-hashtb)) (read buf))))) | |
266 ;; An error. | |
267 ) | |
268 ((not (symbolp group)) | |
269 ;; Ignore invalid entries. | |
270 ) | |
271 ((not (boundp group)) | |
272 ;; Make sure all entries in the hashtb are bound. | |
273 (set group nil)) | |
274 (t | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
275 (when (gnus-gethash (gnus-group-real-name (symbol-name group)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
276 gnus-nocem-real-group-hashtb) |
17493 | 277 ;; Valid group. |
278 (beginning-of-line) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
279 (while (eq (char-after) ?\t) |
17493 | 280 (forward-line -1)) |
281 (setq id (buffer-substring (point) (1- (search-forward "\t")))) | |
282 (unless (gnus-gethash id gnus-nocem-hashtb) | |
283 ;; only store if not already present | |
284 (gnus-sethash id t gnus-nocem-hashtb) | |
285 (push id ncm)) | |
286 (forward-line 1) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
287 (while (eq (char-after) ?\t) |
17493 | 288 (forward-line 1)))))) |
289 (when ncm | |
290 (setq gnus-nocem-touched-alist t) | |
291 (push (cons (let ((time (current-time))) (setcdr (cdr time) nil) time) | |
292 ncm) | |
293 gnus-nocem-alist)) | |
294 t))) | |
295 | |
296 (defun gnus-nocem-load-cache () | |
297 "Load the NoCeM cache." | |
298 (interactive) | |
299 (unless gnus-nocem-alist | |
300 ;; The buffer doesn't exist, so we create it and load the NoCeM | |
301 ;; cache. | |
302 (when (file-exists-p (gnus-nocem-cache-file)) | |
303 (load (gnus-nocem-cache-file) t t t) | |
304 (gnus-nocem-alist-to-hashtb)))) | |
305 | |
306 (defun gnus-nocem-save-cache () | |
307 "Save the NoCeM cache." | |
308 (when (and gnus-nocem-alist | |
309 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
|
310 (with-temp-file (gnus-nocem-cache-file) |
17493 | 311 (gnus-prin1 `(setq gnus-nocem-alist ',gnus-nocem-alist))) |
312 (setq gnus-nocem-touched-alist nil))) | |
313 | |
314 (defun gnus-nocem-save-active () | |
315 "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
|
316 (with-temp-file (gnus-nocem-active-file) |
17493 | 317 (gnus-prin1 `(setq gnus-nocem-active ',gnus-nocem-active)))) |
318 | |
319 (defun gnus-nocem-alist-to-hashtb () | |
320 "Create a hashtable from the Message-IDs we have." | |
321 (let* ((alist gnus-nocem-alist) | |
322 (pprev (cons nil alist)) | |
323 (prev pprev) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
324 (expiry (days-to-time gnus-nocem-expiry-wait)) |
17493 | 325 entry) |
326 (setq gnus-nocem-hashtb (gnus-make-hashtable (* (length alist) 51))) | |
327 (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
|
328 (if (not (time-less-p (time-since (car entry)) expiry)) |
17493 | 329 ;; This entry has expired, so we remove it. |
330 (setcdr prev (cdr alist)) | |
331 (setq prev alist) | |
332 ;; This is ok, so we enter it into the hashtable. | |
333 (setq entry (cdr entry)) | |
334 (while entry | |
335 (gnus-sethash (car entry) t gnus-nocem-hashtb) | |
336 (setq entry (cdr entry)))) | |
337 (setq alist (cdr alist))))) | |
338 | |
339 (gnus-add-shutdown 'gnus-nocem-close 'gnus) | |
340 | |
341 (defun gnus-nocem-close () | |
342 "Clear internal NoCeM variables." | |
343 (setq gnus-nocem-alist nil | |
344 gnus-nocem-hashtb nil | |
345 gnus-nocem-active nil | |
346 gnus-nocem-touched-alist nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
347 gnus-nocem-seen-message-ids nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19539
diff
changeset
|
348 gnus-nocem-real-group-hashtb nil)) |
17493 | 349 |
350 (defun gnus-nocem-unwanted-article-p (id) | |
351 "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
|
352 (and gnus-nocem-hashtb |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
353 (gnus-gethash id gnus-nocem-hashtb))) |
17493 | 354 |
355 (provide 'gnus-nocem) | |
356 | |
357 ;;; gnus-nocem.el ends here |