annotate my-news.el @ 22:6097ab2da4ce

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