dot/gnus-local.el.distorted: Add more split rules.
[profile] / dot / gnus-local.el.distorted
1 ;;; -*-emacs-lisp-*-
2 ;;;
3 ;;; Local GNUS configuration -- distorted.org.uk version
4 ;;;
5 ;;; (c) 2014 Mark Wooding
6 ;;;
7
8 ;;;--------------------------------------------------------------------------
9 ;;; Random configuration.
10
11 (setq auth-sources '("~/.gnus.authinfo"))
12
13 (remove-hook 'gnus-mark-article-hook
14 'gnus-summary-mark-read-and-unread-as-read)
15 (add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
16
17 (setq gnus-level-unsubscribed 6)
18
19 ;;;--------------------------------------------------------------------------
20 ;;; How to send mail.
21
22 (setq smtpmail-smtp-service 587
23 smtpmail-auth-credentials "~/.gnus.authinfo")
24
25 (setq mdw-send-mail-alist
26 `((distorted-smtp
27 (send-mail-function . smtpmail-send-it)
28 (smtpmail-smtp-server . "mail.distorted.org.uk")
29 (smtpmail-starttls-credentials
30 ("mail.distorted.org.uk" 587 nil nil)))
31 (chiark-smtp
32 (send-mail-function . smtpmail-send-it)
33 (smtpmail-smtp-server . "smtp.dovecot.chiark.greenend.org.uk")
34 (starttls-extra-arguments "--insecure")
35 (smtpmail-starttls-credentials
36 ("smtp.dovecot.chiark.greenend.org.uk" 587 nil nil)))
37 (gmail-smtp
38 (send-mail-function . smtpmail-send-it)
39 (smtpmail-smtp-server . "smtp.gmail.com")
40 (smtpmail-starttls-credentials
41 ("smtp.gmail.com" 587 nil nil))))
42 mdw-guess-send-mail-alist
43 `((,(concat "@\\(" "\\(chiark\\|slimy\\|coriolis\\)"
44 "\\.greenend\\.org\\.uk"
45 "\\|" "evade\\.org\\.uk"
46 "\\|" "fyvzl\\.net"
47 "\\)$") . chiark-smtp)
48 ("@g\\(\\|oogle\\)mail\\.com$" . gmail-smtp))
49 mdw-default-send-mail-method nil)
50
51 ;;;--------------------------------------------------------------------------
52 ;;; News via chiark.
53
54 ;; Currently we assume an SSH tunnel. This will be fixed later.
55 (setq gnus-select-method
56 '(nntp "chiark-ssh-kludge"
57 (nntp-open-connection-function nntp-open-authinfo-kludge)
58 (nntp-address "tunnel.chiark.greenend.org.uk")
59 (nntp-authinfo-generic "md5cookie1way mdw")))
60
61 ;;;--------------------------------------------------------------------------
62 ;;; Mail group configuration.
63
64 ;; General splitting configuration.
65 (setq nnimap-split-rule 'nnimap-split-fancy
66 nnmail-split-methods 'nnmail-split-fancy
67 nnimap-split-predicate "UNDELETED"
68 nnimap-split-crosspost t
69 nnmail-split-crosspost t
70 nnmail-split-fancy-match-partial-words nil)
71
72 ;; Automatic expiry for particular groups.
73 (setq gnus-auto-expirable-newsgroups
74 (concat "^"
75 "\\(nnimap\\+[^:]+\\|nnvirtual\\):"
76 "\\(" "\\(admin\\|crap\\|lists\\|nag\\)\\."
77 "\\|" "spam\\.oubliette"
78 "\\)"))
79
80 ;; My various email addresses.
81 (setq message-alternative-emails bbdb-user-mail-names
82 message-dont-reply-to-names message-alternative-emails)
83
84 ;; Mail sent to `mdw-nospam-THING' should appear to come from this address.
85 (setq gnus-posting-styles
86 '(("^nnimap\\+distorted:crap\\."
87 (address (concat "mdw-nospam-"
88 (substring gnus-newsgroup-name (match-end 0))
89 "@distorted.org.uk")))
90 ("^nnimap\\+[^:]+-chiark:"
91 ("X-mdw-Send-Mail" "chiark-smtp"))
92 ("^nnimap\\+google:"
93 (address "distorted.mdw@gmail.com")
94 ("X-mdw-Send-Mail" "gmail-smtp"))))
95
96 (setq nnmail-split-abbrev-alist
97 (mdw-uniquify-alist
98 `((to . ,(concat "to\\|cc\\|apparently-to\\|envelope-to\\|"
99 "resent-to\\|resent-cc"))
100 (any . ,(concat "from\\|sender\\|resent-from\\|"
101 "to\\|cc\\|apparently-to\\|envelope-to\\|"
102 "resent-to\\|resent-cc"))
103 ,@nnmail-split-abbrev-alist)))
104
105 (defvar mdw-odin-parse-regexp
106 (concat "^"
107 "\\S-+" "\\s-+" ; time limit
108 "\\(" "\\S-+" "\\)" "\\s-+" ; local part
109 "\\S-+" "\\s-+" ; recipient email address
110 "=" "\\(" "\\S-+" "\\)" ; mailbox tag
111 "\\(" "$" "\\|" "\\s-" "\\)"))
112
113 (defun mdw-odin-splits ()
114 (let ((list nil))
115 (with-temp-buffer
116 (call-process "ssh" nil t nil
117 "stratocaster" "userv" "odin" "mail" "list")
118 (goto-char (point-min))
119 (while (< (point) (point-max))
120 (when (looking-at mdw-odin-parse-regexp)
121 (let ((local-part (match-string 1))
122 (tag (match-string 2)))
123 (push `(to ,(format "%s@odin\\.gg" local-part)
124 ,(format "crap.%s" tag))
125 list)))
126 (forward-line)))
127 (nreverse list)))
128
129 ;; The actual splitting rules.
130 (setq nnmail-split-fancy
131 `(|
132 ;; Administrative boxes.
133 (to "\\<\\(root\\|postgres\\|ca\\|noc\\)@" "admin.misc" t)
134 (to "\\<\\(jukebox\\|nobody\\|darchive\\)@" "admin.misc" t)
135 (to "\\<\\(hostmaster\\)@" "admin.dns" t)
136 (to "\\<\\(news\\|newsmaster\\|usenet\\)@" "admin.news" t)
137 (to "\\<\\(postmaster\\|spamd\\|mailer-daemon\\)@" "admin.mail" t)
138 (to "\\<\\(irc\\|blight\\|ircbot\\)@" "admin.irc" t)
139 (to "\\<\\(www\\|webmaster\\|mtos\\)@" "admin.web" t)
140 (to "\\<\\(ftp\\|ftpadmin\\|mirror\\)@" "admin.ftp" t)
141 (to "\\\<\\(abuse\\|security\\)@" "admin.keep" t)
142 (from "cron daemon" "admin.misc")
143 (from "uucp@distorted\\.org\\.uk" "admin.uucp")
144 (from "darchive@.*\\.distorted\\.org\\.uk" "admin.misc")
145 (from "support@aa\\.net\\.uk" "admin.aaisp")
146 (from "bugs@distorted\\.org\\.uk" "admin.bugs")
147 (from "darchive@distorted\\.org\\.uk" "admin.darchive")
148
149 ;; Colo and network provider.
150 (from "\\(accounts\\|support\\)@jump\\.net\\.uk" "keep.colo")
151 (from "\\(accounts\\|support\\)@aa\\.net\\.uk" "keep.aaisp")
152
153 ;; Mailing lists, not split out earlier.
154 (to "python-list@python\\.org" "lists.python")
155 (to ,(concat "\\(jump-\\(announce\\|discuss\\)\\)@"
156 "\\(lists\\.\\|\\)" "jump\\.net\\.uk")
157 "lists.\\1")
158 (to "cambridgecryptowhiskyclub@gmail\\.com"
159 "lists.cambridge-crypto-whisky")
160 (from ,(concat "@" "\\(" "liberty-human-rights"
161 "\\|" "libertyhumanrights"
162 "\\|" "libertymail"
163 "\\)" "\\.org\\.uk" "\\>")
164 "lists.liberty" t)
165 (from "@openrightsgroup\\.org\\>" "lists.org" t)
166 (from "@warwick\\.ac\\.uk\\>" "lists.warwick-uni" t)
167 (to "chiark-\\(motd\\|announce\\)@chiark\\.greenend\\.org\\.uk"
168 "lists.chiark-announce")
169 (any "clive-cambridge-gamers@nsict\\.org" "lists.nsict-games")
170
171 ;; Per-sender addresses.
172 (to "\\<mdw-nospam-justgviing@" "crap.justgiving" t)
173 (to "\\<mdw-nospam-\\([^@]+\\)@" "crap.\\1" t)
174 (to "\\<mdw-nopspam-\\([^@]+\\)@" "crap.\\1" t)
175
176 (to "\\(markw\\|mdw\\|mw\\)@odin\\.gg" "mail.misc")
177 ,@(mdw-odin-splits)
178 (to "\\([a-z0-9]+\\)@odin\\.gg" "crap.odin-misc")
179
180 ;; Regular nags.
181 (from "\\(sealbot\\|cardbot\\)@ncipher\\.com" "nag.cardbot")
182 (from "\\<mailman-owner@" "nag.mailman" t)
183
184 ;; Uninteresting mail.
185 (from "expiry@letsencrypt\\.org" "admin.letsencrypt")
186
187 ;; Other splits I've not given a per-sender address.
188 (from "@\\(.*\\.\\)?lovefilm\\.com\\>" "crap.lovefilm" t)
189 (from "@\\(\\|.*\\.\\)amazon\\." "crap.amazon" t)
190 (from "@cineworldmail\\.com\\>" "crap.cineworld" t)
191 (from "@picturehouses\\.co\\.uk\\>" "crap.picturehouse" t)
192 (from "@nationwide" "crap.nationwide" t)
193 (from "nationwide@securesuiteemail\\.com\\>" "crap.nationwide" t)
194 (from "@news\\.spotifymail\\.com\\>" "crap.spotify" t)
195 (from "@action\\.openrightsgroup\\.org\\>" "crap.org" t)
196 (from "unlimited@cineworld\\.com\\>" "crap.cineworld" t)
197 (from "@tshirthell\\.com\\>" "crap.tshirt-hell" t)
198 (from "campaigns@jolla\\.com\\>" "crap.jolla" t)
199 (from "@thomann\\.de\\>" "crap.thomann" t)
200 (from "@wikimedia\\.org\\>" "crap.wikimedia" t)
201 (from "@gandi\\.net\\>" "crap.gandi" t)
202 (from "@mythic-beasts\\.com\\>" "crap.mythic-beasts" t)
203
204 ;; Default.
205 "mail.misc"))
206
207 ;;;--------------------------------------------------------------------------
208 ;;; Where we get mail from.
209
210 ;; Read mail on the IMAP server.
211 (setq gnus-secondary-select-methods
212 `((nnimap "distorted"
213 (nnimap-address "mail.distorted.org.uk")
214 (nnimap-stream starttls)
215 (nnimap-inbox ("INBOX" "to.split"))
216 (nnimap-split-methods nnimap-split-fancy)
217 (nnimap-split-fancy ,nnmail-split-fancy)
218 (nnimap-unsplittable-articles (%Deleted)))
219 (nnimap "markw-distorted"
220 (nnimap-address "mail.distorted.org.uk")
221 (nnimap-stream starttls)
222 (nnimap-inbox ("INBOX" "to.split"))
223 (nnimap-split-methods nnimap-split-fancy)
224 (nnimap-split-fancy ,nnmail-split-fancy)
225 (nnimap-unsplittable-articles (%Deleted)))
226 (nnimap "mwooding-chiark"
227 (nnimap-address "imap.dovecot.chiark.greenend.org.uk")
228 (nnimap-stream starttls)
229 (nnimap-inbox "INBOX")
230 (nnimap-unsplittable-articles (%Deleted)))
231 (nnimap "google"
232 (nnimap-address "imap.gmail.com")
233 (nnimap-stream tls)
234 (nnimap-inbox "INBOX")
235 (nnimap-unsplittable-articles (%Deleted)))))
236
237 ;; Send sent mail back to me.
238 (setq gnus-message-archive-method "mail"
239 gnus-gcc-mark-as-read t
240 gnus-message-archive-group "nnimap+distorted:mail.sent")
241
242 ;;;----- That's all, folks --------------------------------------------------