annotate my-news.el @ 24:0e5b39d2f8bb

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