21
|
1 ;; Last edited: Wed Aug 25 14:10:36 1999
|
|
2
|
|
3 ;(site-caseq (edin (require 'ccs-gnus)))
|
|
4
|
|
5 ; mix-spool stuff
|
|
6
|
|
7 (load "gnus" nil t)
|
|
8 ; (debug-on-entry 'gnus-start-news-server)
|
|
9 (setq gnus-nntp-server nil)
|
|
10 ;
|
|
11
|
|
12
|
|
13 (setq gnus-article-save-directory "/home/ht/mail/Mail")
|
|
14 (setq nnml-directory (expand-file-name "/home/ht/mail/Mail"))
|
|
15 (setq gnus-message-archive-method
|
|
16 '(nnfolder "archive"
|
24
|
17 ;; the following two are not taking effect, not sure why, answer
|
|
18 ;; _may_ lie in gnus-setup-news...
|
21
|
19 (nnfolder-directory "/home/ht/mail/cpy")
|
|
20 (nnfolder-active-file "/home/ht/mail/cpy/active")
|
|
21 (nnfolder-get-new-mail nil)
|
|
22 (nnfolder-inhibit-expiry t)))
|
|
23 (setq gnus-secondary-select-methods
|
|
24 '((nnml "ht"
|
|
25 (gnus-show-threads nil)
|
|
26 (gnus-article-sort-functions (gnus-article-sort-by-subject gnus-article-sort-by-date))
|
|
27 )))
|
|
28 (setq mail-sources '((file :path "/var/spool/mail/ht")))
|
|
29 ;;; fixup clarinews
|
|
30 ;(autoload 'gnus-clarinews-fun "clari-clean" "Clean ClariNews articles" t)
|
|
31 ;(add-hook 'gnus-article-prepare-hook 'gnus-clarinews-fun)
|
|
32
|
|
33
|
|
34 (defun gnus-Subject-sort-by-subject-and-date (reverse)
|
|
35 "Sort subject display buffer by subject alphabetically. `Re:'s are ignored.
|
|
36 If case-fold-search is non-nil, case of letters is ignored. Date is used
|
|
37 if subjects are equal
|
|
38 Argument REVERSE means reverse order."
|
|
39 (interactive "P")
|
|
40 (gnus-summary-sort-summary
|
|
41 (function
|
|
42 (lambda (a b)
|
|
43 (let ((s-a (gnus-trim-simplify-subject (nntp-header-subject a)))
|
|
44 (s-b (gnus-trim-simplify-subject (nntp-header-subject b)))
|
|
45 )
|
|
46 (or (gnus-string-lessp s-a s-b)
|
|
47 (and (gnus-string-equal s-a s-b)
|
|
48 (gnus-date-lessp (nntp-header-date a)
|
|
49 (nntp-header-date b)))))))
|
|
50 reverse
|
|
51 ))
|
|
52
|
|
53 ;(require 'util-mde) ; for string-replace-regexp-2
|
|
54 (defun gnus-trim-simplify-subject (text)
|
|
55 "call gnus-simplify-subject and remove leading blanks"
|
|
56 (if text
|
|
57 (gnus-simplify-subject
|
|
58 (string-replace-regexp-2
|
|
59 (gnus-simplify-subject text t)
|
|
60 "^\\s-+"
|
|
61 "")
|
|
62 t)
|
|
63 ""))
|
|
64
|
|
65 (defun gnus-string-equal (a b)
|
|
66 "Return T if first arg string is equal than second in lexicographic order.
|
|
67 If case-fold-search is non-nil, case of letters is ignored."
|
|
68 (if case-fold-search
|
|
69 (string-equal (downcase a) (downcase b)) (string-equal a b)))
|
|
70
|
|
71 (defun gnus-Group-update-and-vanish ()
|
|
72 "update newsrc and restore config pre-group selection"
|
|
73 (interactive)
|
|
74 (gnus-group-force-update)
|
|
75 (if gnus-pre-config
|
|
76 (set-window-configuration gnus-pre-config))
|
|
77 ; (setq gnus-pre-config nil)
|
|
78 )
|
|
79
|
|
80 ;; Database stuff
|
|
81 (defun open-white ()
|
|
82 (setq whitelist-db (open-database "/disk/scratch/mail/white" 'berkeley-db)))
|
|
83 (defun save-white ()
|
|
84 (close-database whitelist-db)
|
|
85 (open-white))
|
|
86
|
|
87 (defun open-ad ()
|
|
88 (setq adlist-db (open-database "/disk/scratch/mail/ad" 'berkeley-db)))
|
|
89
|
|
90 (defun save-ad ()
|
|
91 (close-database adlist-db)
|
|
92 (open-ad))
|
|
93
|
|
94 (defun open-quaker ()
|
|
95 (setq quaker-db (open-database "~/mail/quaker" 'berkeley-db)))
|
|
96 (defun save-quaker ()
|
|
97 (close-database quaker-db)
|
|
98 (open-quaker))
|
|
99
|
|
100
|
|
101 (defun add-white (&optional addToBBDB)
|
|
102 (interactive "P")
|
|
103 (gnus-summary-goto-article (gnus-summary-article-number))
|
|
104 (let* ((components (get-current-from-components))
|
|
105 (addr (get-canonical-from-addr components)))
|
|
106 (if (new-white addr)
|
|
107 (save-white))
|
|
108 (if addToBBDB
|
|
109 (let ((bbdb-no-duplicates-p t))
|
|
110 (bbdb-create-internal (car components) nil (cadr components)
|
|
111 nil nil nil)))))
|
|
112
|
|
113 (defun add-ad ()
|
|
114 (interactive)
|
|
115 (gnus-summary-goto-article (gnus-summary-article-number))
|
|
116 (let ((addr (get-current-from-addr)))
|
|
117 (if (or (not (get-database addr whitelist-db))
|
|
118 (yes-or-no-p "Already white, really convert to ad?"))
|
|
119 (if (new-ad addr)
|
|
120 (save-ad)))))
|
|
121
|
|
122 (defun add-quaker()
|
|
123 (interactive)
|
|
124 (let ((addr (get-addr-before-point)))
|
|
125 (when (new-quaker addr)
|
|
126 (save-quaker))
|
|
127 (quaker-sig-maybe)))
|
|
128
|
|
129 ; not needed anymore because of gnus-posting-styles (q.v. in gnus-init)
|
|
130 (defun quaker-sig-if-to-quaker ()
|
|
131 (let ((message-options))
|
|
132 (save-excursion (message-options-set-recipient))
|
|
133 (let* ((recipStr (message-options-get 'message-recipients))
|
|
134 (recips (split-string (downcase recipStr)
|
|
135 ",[ \f\t\n\r\v]+" t)))
|
|
136 (while (and recips
|
|
137 (not (quaker-sig-if-quaker-1 (car recips))))
|
|
138 (setq recips (cdr recips))))))
|
|
139
|
|
140 (defun to-quaker-p ()
|
|
141 (let ((message-options))
|
|
142 (save-excursion (message-options-set-recipient))
|
|
143 (let* ((recipStr (message-options-get 'message-recipients))
|
|
144 (recips (split-string (downcase recipStr)
|
|
145 ",[ \f\t\n\r\v]+" t)))
|
|
146 (while (and recips
|
|
147 (not (get-database (car recips) quaker-db)))
|
|
148 (setq recips (cdr recips)))
|
|
149 (not (null recips)))))
|
|
150
|
|
151 (defun quaker-sig-if-quaker ()
|
|
152 (quaker-sig-if-quaker-1 (get-addr-before-point)))
|
|
153
|
|
154 (defun quaker-sig-if-quaker-1 (addr)
|
|
155 (if (get-database addr quaker-db)
|
|
156 (progn (quaker-sig-maybe)
|
|
157 t)))
|
|
158
|
|
159 (defun quaker-sig-maybe ()
|
|
160 (save-excursion
|
|
161 (goto-char (point-min))
|
|
162 (cond ((to-quaker-p)
|
|
163 (goto-char (point-min))
|
|
164 (cond ((search-forward "\nFrom: ht@home.hst.name" nil t)
|
|
165 (backward-char 13)
|
|
166 (delete-char 4)
|
|
167 (insert "rsof")))))
|
|
168
|
|
169 (goto-char (point-max))
|
|
170 (search-backward "\n-- \n")
|
|
171 (when (looking-at "\n-- \nHenry")
|
|
172 (forward-char 5)
|
|
173 (kill-entire-line 5)
|
|
174 (insert-file "~/.quaker-sig"))))
|
|
175
|
|
176 (defun kill-white ()
|
|
177 (interactive)
|
|
178 (gnus-summary-goto-article (gnus-summary-article-number))
|
|
179 (let ((addr (get-current-from-addr)))
|
|
180 (rem-white addr)))
|
|
181
|
|
182 (defun get-from-gnus-addr ()
|
|
183 (get-from-addr (gnus-fetch-field "From")))
|
|
184
|
|
185 (defun get-from-addr (addr)
|
|
186 (get-canonical-from-addr (gnus-extract-address-components addr)))
|
|
187
|
|
188 (defun get-canonical-from-addr (components)
|
|
189 (downcase (cadr components)))
|
|
190
|
|
191 (defun get-current-from-addr ()
|
|
192 (with-current-buffer gnus-article-buffer
|
|
193 (get-from-gnus-addr)))
|
|
194
|
|
195 (defun get-current-from-components ()
|
|
196 (with-current-buffer gnus-article-buffer
|
|
197 (gnus-extract-address-components (gnus-fetch-field "From"))))
|
|
198
|
|
199 (defun get-addr-before-point ()
|
|
200 (let ((cur (point)))
|
|
201 (save-excursion
|
|
202 (get-from-addr (buffer-substring (+ (search-backward " ") 1) cur)))
|
|
203 ))
|
|
204
|
|
205 (defun blacken-and-delete (group)
|
|
206 ;; mis-named now
|
|
207 ;; this is part of the expiry processing for xxxSPAM groups, and
|
|
208 ;; actually whitens the from addresses of #-marked articles
|
|
209 ;; The return value is crucial (and crucially outside of the scope of the if)
|
|
210 (if (memq number
|
|
211 (with-current-buffer gnus-summary-buffer
|
|
212 gnus-newsgroup-processable))
|
|
213 (let ((addr (get-from-gnus-addr)))
|
|
214 (new-white addr)))
|
|
215 'delete)
|
|
216
|
|
217 (defun unwhiten-and-delete (group)
|
|
218 ;; unused except in stale groups -- usable as an expiry
|
|
219 (if (memq number
|
|
220 (with-current-buffer gnus-summary-buffer
|
|
221 gnus-newsgroup-processable))
|
|
222 (let ((addr (get-from-gnus-addr)))
|
|
223 (remove-database addr whitelist-db)))
|
|
224 'delete)
|
|
225
|
|
226 (defun known-black (list)
|
|
227 (if (get-database (get-from-gnus-addr) blacklist-db)
|
|
228 list))
|
|
229
|
|
230 (defun white-spam (list)
|
|
231 (if (or (equal (get-database (get-from-gnus-addr) whitelist-db) "t")
|
|
232 (let ((case-fold-search t)
|
|
233 (subj (gnus-fetch-field "Subject"))
|
|
234 (from (get-from-gnus-addr)))
|
|
235 (or
|
|
236 (and subj (string-match white-subjects subj))
|
|
237 (and from
|
|
238 (let ((fromDom (substring from (+ 1 (search "@" from)))))
|
|
239 (and fromDom (member fromDom white-domains)))))))
|
|
240 list))
|
|
241
|
|
242 (defun ad-spam (list)
|
|
243 (if (let ((from (get-from-gnus-addr)))
|
|
244 (or
|
|
245 (equal (get-database from adlist-db) "t")
|
|
246 (and from
|
|
247 (let ((fromDom (substring from (+ 1 (search "@" from)))))
|
|
248 (and fromDom (member fromDom ad-domains))))
|
|
249 ))
|
|
250 list))
|
|
251
|
|
252 (defun bogoNote (group)
|
|
253 (if (memq number
|
|
254 (with-current-buffer gnus-summary-buffer
|
|
255 gnus-newsgroup-processable))
|
|
256 (let ((addr (get-from-gnus-addr)))
|
|
257 (new-white addr)))
|
|
258 (shell-command-on-region (point-min) (point-max)
|
|
259 "/afs/inf.ed.ac.uk/user/h/ht/share/bin/local/makeBogo")
|
|
260 'delete)
|
|
261
|
|
262 (defun whiten-recip ()
|
|
263 ;;; a hook for outgoing mail
|
|
264 (let* ((recips (message-options-get 'message-recipients))
|
|
265 (res (mapcar (function new-white)
|
|
266 (split-string (downcase recips)
|
|
267 ",[ \f\t\n\r\v]*" t))))
|
|
268 (while (and res (not (car res)))
|
|
269 (setq res (cdr res)))
|
|
270 (if res (save-white))))
|
|
271
|
|
272
|
|
273 (defun new-white (addr)
|
|
274 (if (get-database addr whitelist-db)
|
|
275 nil
|
|
276 (put-database addr "t" whitelist-db)
|
|
277 t))
|
|
278
|
|
279 (defun new-ad (addr)
|
|
280 (if (get-database addr adlist-db)
|
|
281 nil
|
|
282 (put-database addr "t" adlist-db)
|
|
283 t))
|
|
284
|
|
285 (defun rem-ad ()
|
|
286 (interactive)
|
|
287 (remove-database (downcase (get-current-from-addr)) adlist-db)
|
|
288 (save-ad))
|
|
289
|
|
290 (defun new-quaker (addr)
|
|
291 (if (get-database addr quaker-db)
|
|
292 nil
|
|
293 (put-database addr "t" quaker-db)
|
|
294 t))
|
|
295
|
|
296 (defun rem-white (addr)
|
|
297 (remove-database (downcase addr) whitelist-db))
|
|
298
|
|
299 (defun bogoOK (group)
|
|
300 (shell-command-on-region (point-min) (point-max)
|
|
301 "/afs/inf.ed.ac.uk/user/h/ht/share/bin/local/makeNonBogo")
|
|
302 'delete)
|
|
303
|
|
304 (defun del-dups ()
|
|
305 (interactive)
|
|
306 (gnus-summary-sort-by-subject)
|
|
307 (gnus-summary-clear-mark-forward 1)
|
|
308 (goto-char (point-min))
|
|
309 (let ((pos))
|
|
310 (while (setq pos (search-forward "] " nil t))
|
|
311 (end-of-line)
|
|
312 (let ((subj (buffer-substring pos (point))))
|
|
313 (unless (equal subj "")
|
|
314 (let ((target (if (< (length subj) 26)
|
|
315 (concat "] " subj "\n")
|
|
316 (concat "] " (substring subj 0 25))))
|
|
317 (done 0)
|
|
318 (case-fold-search nil))
|
|
319 (while (and (= done 0)
|
|
320 (search-forward target nil t))
|
|
321 (forward-char -3)
|
|
322 (setq done (gnus-summary-mark-as-read-forward 1))))))))
|
|
323 (gnus-summary-limit-to-unread)
|
|
324 (gnus-summary-sort-by-original))
|
|
325
|
|
326
|
|
327 (defun showMPAhtml ()
|
|
328 "Show the text/html parts of an multipart/alternative message using lynx"
|
|
329 (interactive)
|
|
330 (gnus-summary-select-article)
|
|
331 (with-current-buffer gnus-original-article-buffer
|
|
332 (shell-command-on-region (point-min) (point-max) "/home/ht/bin/showMPA.sh")
|
|
333 )
|
|
334 )
|
|
335
|
|
336 (provide 'my-news)
|