dot/gpg.conf.m4, dot/gpg-agent.conf, Makefile: Adopt GnuPG configuration.
[profile] / dot / gnus-local.el.distorted
index 161aae4..00f46d6 100644 (file)
 ;;; (c) 2014 Mark Wooding
 ;;;
 
+(setq auth-sources '("~/.authinfo.gpg"))
+
 ;;;--------------------------------------------------------------------------
 ;;; How to send mail.
 
-(and nil
-     (setq smtpmail-smtp-server "mail.distorted.org.uk"
-          smtpmail-sendto-domain "distorted.org.uk"
-          smtpmail-smtp-service 587
-          smtpmail-auth-credentials "~/.gnus.authinfo"
-          message-send-mail-function 'smtpmail-send-it
-          smtpmail-starttls-credentials
-          '(("mail.distorted.org.uk" 587 "" ""))))
+(setq smtpmail-smtp-service 587
+      smtpmail-auth-credentials "~/.authinfo.gpg")
 
-;;;--------------------------------------------------------------------------
-;;; Where we get mail from.
+(setq mdw-send-mail-alist
+      `((distorted-smtp
+        (send-mail-function . smtpmail-send-it)
+        (smtpmail-smtp-server . "mail.distorted.org.uk")
+        (smtpmail-starttls-credentials
+         ("mail.distorted.org.uk" 587 nil nil)))
+       (chiark-smtp
+        (send-mail-function . smtpmail-send-it)
+        (smtpmail-smtp-server . "smtp.dovecot.chiark.greenend.org.uk")
+        (starttls-extra-arguments "--insecure")
+        (smtpmail-starttls-credentials
+         ("smtp.dovecot.chiark.greenend.org.uk" 587 nil nil)))
+       (gmail-smtp
+        (send-mail-function . smtpmail-send-it)
+        (smtpmail-smtp-server . "smtp.gmail.com")
+        (smtpmail-starttls-credentials
+         ("smtp.gmail.com" 587 nil nil))))
+      mdw-guess-send-mail-alist
+      `((,(concat "@\\(" "\\(chiark\\|slimy\\|coriolis\\)"
+                        "\\.greenend\\.org\\.uk"
+                 "\\|"  "evade\\.org\\.uk"
+                 "\\|"  "fyvzl\\.net"
+                 "\\)$") . chiark-smtp)
+       ("@g\\(oogle\\)?mail\\.com$" . gmail-smtp))
+      mdw-default-send-mail-method nil)
 
-;; Read mail on the IMAP server.
-(setq gnus-secondary-select-methods
-      '((nnimap "distorted"
-               (nnimap-address "mail.distorted.org.uk")
-               (nnimap-stream tls)
-               (nnimap-authinfo-file "~/.gnus.authinfo"))))
+;;;--------------------------------------------------------------------------
+;;; News via chiark.
 
-;; Send sent mail back to me.
-(setq gnus-message-archive-method "mail"
-      gnus-gcc-mark-as-read t
-      gnus-message-archive-group "nnimap+distorted:mail.sent")
+;; Currently we assume an SSH tunnel.  This will be fixed later.
+(setq gnus-select-method
+      '(nntp "chiark-ssh-kludge"
+            (nntp-open-connection-function nntp-open-authinfo-kludge)
+            (nntp-address "tunnel.chiark.greenend.org.uk")
+            (nntp-authinfo-generic "md5cookie1way mdw")))
 
 ;;;--------------------------------------------------------------------------
 ;;; Mail group configuration.
 
 ;; General splitting configuration.
-(setq nnimap-split-inbox '("INBOX" "to.split")
-      nnimap-split-rule 'nnimap-split-fancy
-      nnimap-split-crosspost t
+(setq nnimap-split-rule 'nnimap-split-fancy
+      nnmail-split-methods 'nnmail-split-fancy
       nnimap-split-predicate "UNDELETED"
+      nnimap-split-crosspost t
+      nnmail-split-crosspost t
       nnmail-split-fancy-match-partial-words nil)
 
 ;; Automatic expiry for particular groups.
 (setq gnus-auto-expirable-newsgroups
-      "^nnimap\\+distorted:\\(crap\\|spam\\|admin\\|lists\\|nag\\)\\..*")
+      (concat "^"
+             "\\(nnimap\\+[^:]+\\|nnvirtual\\):"
+             "\\(" "\\(admin\\|crap\\|lists\\|nag\\)\\."
+             "\\|" "spam\\.oubliette"
+             "\\)"))
+
+;; My various email addresses.
+(setq message-alternative-emails bbdb-user-mail-names
+      message-dont-reply-to-names message-alternative-emails)
+
+;; Augment Gnus's built-in header-list abbreviations.
+(require 'nnmail)
+(setq nnmail-split-abbrev-alist
+      (mdw-uniquify-alist
+       `((to . ,(concat "to\\|cc\\|apparently-to\\|envelope-to\\|"
+                       "resent-to\\|resent-cc"))
+        (any . ,(concat "from\\|sender\\|resent-from\\|"
+                        "to\\|cc\\|apparently-to\\|envelope-to\\|"
+                        "resent-to\\|resent-cc"))
+        ,@nnmail-split-abbrev-alist)))
+
+;; Find out about my `odin.gg' mappings.
+(defvar mdw-odin-parse-regexp
+  (concat "^"
+         "\\S-+" "\\s-+"               ; time limit
+         "\\(" "\\S-+" "\\)" "\\s-+"   ; local part
+         "\\S-+" "\\s-+"               ; recipient email address
+         "=" "\\(" "\\S-+" "\\)"       ; mailbox tag
+         "\\(" "$" "\\|" "\\s-" "\\)"))
+
+(defvar mdw-odin-splits nil)
+(defvar mdw-odin-sender-alist nil)
+
+(defun mdw-update-odin-info ()
+  (let ((splits nil) (senders nil))
+    (with-temp-buffer
+      (call-process "ssh" nil t nil
+                   "stratocaster" "userv" "odin" "mail" "list")
+      (goto-char (point-min))
+      (while (< (point) (point-max))
+       (when (looking-at mdw-odin-parse-regexp)
+         (let ((local-part (match-string 1))
+               (tag (match-string 2)))
+           (push `(to ,(format "%s@odin\\.gg" local-part)
+                      ,(format "crap.%s" tag))
+                 splits)
+           (push (cons tag local-part) senders)))
+       (forward-line)))
+    (setq mdw-odin-splits (nreverse splits)
+         mdw-odin-sender-alist (nreverse senders))))
+(mdw-update-odin-info)
 
 ;; Mail sent to `mdw-nospam-THING' should appear to come from this address.
 (setq gnus-posting-styles
-      '(((and (string-match "^nnimap\\+distorted:crap\\.\\(.*\\)$"
-                           gnus-newsgroup-name)
-             (setq mdw-from-address
-                   (replace-match "mdw-nospam-\\1@distorted.org.uk"
-                                  nil nil gnus-newsgroup-name)))
-        ("From" mdw-from-address))))
+      '(("^nnimap\\+distorted:crap\\."
+        (address (let* ((mailbox (substring gnus-newsgroup-name
+                                            (match-end 0)))
+                        (entry (assoc mailbox mdw-odin-sender-alist)))
+                   (if entry (concat (cdr entry) "@odin.gg")
+                     (concat "mdw-nospam-" mailbox "@distorted.org.uk")))))
+       ("^nnimap\\+[^:]+-chiark:"
+        ("X-mdw-Send-Mail" "chiark-smtp"))
+       ("^nnimap\\+google:"
+        (address "distorted.mdw@gmail.com")
+        ("X-mdw-Send-Mail" "gmail-smtp"))))
 
 ;; The actual splitting rules.
-(setq nnimap-split-fancy
-      '(| (to "\\<\\(news\\|newsmaster\\|usenet\\)@" "admin.news" t)
-         (to "\\<hostmaster@" "admin.dns" t)
-         (to "\\<postmaster@" "admin.mail" t)
-         (to "\\<\\(root\\|mirror\\|postgres\\|spamd\\)@" "admin.misc" t)
-         (to "python-list@python\\.org" "lists.python")
-         (to "tinycc-devel@nongnu\\.org" "lists.tcc")
-         (to "mdw-nospam-\\([^@]+\\)@" "crap.\\1" t)
-         (to "\\(^\\|\\s-\\|[<]\\)\\([-a-z0-9]+\\)@lists\\.debian\\.org" "lists.\\2" t)
-         (to "stds-p1363\\(-discuss\\)?@listserv.ieee.org" "lists.p1363")
-         (to "jump-announce@jump\\.net\\.uk" "lists.jump-announce")
-         (to "jump-discuss@jump\\.net\\.uk" "lists.jump-discuss")
-         (from "support@jump\\.net\\.uk" "keep.colo")
-         (from "\\(sealbot\\|cardbot\\)@ncipher\\.com" "nag.cardbot")
-         (from "\\<mailman-owner@" "nag.mailman" t)
+(setq nnmail-split-fancy
+      `(|
+         ;; Administrative boxes.
+         (to "\\<\\(root\\|postgres\\|ca\\|noc\\)@" "admin.misc" t)
+         (to "\\<\\(jukebox\\|nobody\\|darchive\\)@" "admin.misc" t)
+         (to "\\<\\(hostmaster\\)@" "admin.dns" t)
+         (to "\\<\\(news\\|newsmaster\\|usenet\\)@" "admin.news" t)
+         (to "\\<\\(postmaster\\|spamd\\|mailer-daemon\\)@" "admin.mail" t)
+         (to "\\<\\(irc\\|blight\\|ircbot\\)@" "admin.irc" t)
+         (to "\\<\\(www\\|webmaster\\|mtos\\)@" "admin.web" t)
+         (to "\\<\\(ftp\\|ftpadmin\\|mirror\\)@" "admin.ftp" t)
+         (to "\\\<\\(abuse\\|security\\)@" "admin.keep" t)
          (from "cron daemon" "admin.misc")
          (from "uucp@distorted\\.org\\.uk" "admin.uucp")
          (from "darchive@.*\\.distorted\\.org\\.uk" "admin.misc")
-         (from "@\\(.*\\.\\)?lovefilm\\.com" "spam.lovefilm" t)
-         (from "@amazon\\." "spam.amazon" t)
-         (from "@cineworldmail\\.com" "spam.cineworld" t)
-         (from "@picturehouses\\.co\\.uk" "spam.picturehouse" t)
-         (from "@nationwide" "spam.nationwide" t)
-         (from "@news\\.spotifymail\\.com" "spam.spotify" t)
-         (from "@action\\.openrightsgroup\\.org" "spam.org" t)
-         (from "unlimited@cineworld\\.com" "spam.cineworld" t)
-         (from "nationwide@securesuiteemail\\.com" "spam.nationwide" t)
-         (from "@tshirthell\\.com" "spam.tshirt-hell" t)
+         (from "sales@aa\\.net\\.uk" "admin.aaisp")
+         (from "support@aa\\.net\\.uk" "admin.aaisp")
+         (from "bugs@distorted\\.org\\.uk" "admin.bugs")
+         (from "darchive@distorted\\.org\\.uk" "admin.darchive")
+
+         ;; Colo and network provider.
+         (from "\\(accounts\\|support\\)@jump\\.net\\.uk" "keep.colo")
+         (from "\\(accounts\\|support\\)@aa\\.net\\.uk" "keep.aaisp")
+
+         ;; Mailing lists, not split out earlier.
+         (to "python-list@python\\.org" "lists.python")
+         (to ,(concat "\\(jump-\\(announce\\|discuss\\|vps\\)\\)@"
+                      "\\(lists\\.\\)?" "jump\\.net\\.uk")
+             "lists.\\1")
+         (to "cambridgecryptowhiskyclub@gmail\\.com"
+             "lists.cambridge-crypto-whisky")
+         (from ,(concat "@" "\\(" "liberty-human-rights"
+                            "\\|" "libertyhumanrights"
+                            "\\|" "libertymail"
+                            "\\)" "\\.org\\.uk" "\\>")
+               "lists.liberty" t)
+         (from "@openrightsgroup\\.org\\>" "lists.org" t)
+         (from "@warwick\\.ac\\.uk\\>" "lists.warwick-uni" t)
+         (to "chiark-\\(motd\\|announce\\)@chiark\\.greenend\\.org\\.uk"
+             "lists.chiark-announce")
+         (to "sot@dotat\\.at" "lists.sot" t)
+         (any "clive-cambridge-gamers@nsict\\.org" "lists.nsict-games")
+
+         ;; Per-sender addresses.
+         (to "\\<mdw-nospam-justgviing@" "crap.justgiving" t)
+         (to "\\<mdw-nospam-\\([^@]+\\)@" "crap.\\1" t)
+         (to "\\<mdw-nopspam-\\([^@]+\\)@" "crap.\\1" t)
+
+         (to "\\(markw\\|mdw\\|mw\\)@odin\\.gg" "mail.misc")
+         ,@mdw-odin-splits
+         (to "\\([a-z0-9]+\\)@odin\\.gg" "crap.odin-misc")
+
+         ;; Regular nags.
+         (from "\\(sealbot\\|cardbot\\)@ncipher\\.com" "nag.cardbot")
+         (from "\\<mailman-owner@" "nag.mailman" t)
+
+         ;; Uninteresting mail.
+         (from "expiry@letsencrypt\\.org" "admin.letsencrypt")
+
+         ;; Other splits I've not given a per-sender address.
+         (from "@\\([^.]+\\.\\)?aegon" "crap.aegon" t)
+         (from "@\\(.*\\.\\)?amazon\\." "crap.amazon" t)
+         (from "@\\(.*\\.\\)?primevideo\\." "crap.amazon" t)
+         (from "@cineworldmail\\.com\\>" "crap.cineworld" t)
+         (from "unlimited@cineworld\\.com\\>" "crap.cineworld" t)
+         (from "@\\(.*\\.\\)?gandi\\.net\\>" "crap.gandi" t)
+         (from "@accounts\\.google\\.com\\>" "crap.google" t)
+         (from "campaigns@jolla\\.com\\>" "crap.jolla" t)
+         (from "@\\(.*\\.\\)?lovefilm\\.com\\>" "crap.lovefilm" t)
+         (from "@mythic-beasts\\.com\\>" "crap.mythic-beasts" t)
+         (from "@\\([^.]+\\.\\)?nationwide" "crap.nationwide" t)
+         (from "nationwide@securesuiteemail\\.com\\>" "crap.nationwide" t)
+         (from "@action\\.openrightsgroup\\.org\\>" "crap.org" t)
+         (from "@picturehouses\\.co\\.uk\\>" "crap.picturehouse" t)
+         (from "@\\(.*\\.\\)?spotify\\(mail\\)?\\.com\\>" "crap.spotify" t)
+         (from "@thomann\\.de\\>" "crap.thomann" t)
+         (from "@tshirthell\\.com\\>" "crap.tshirt-hell" t)
+         (from "@wikimedia\\.org\\>" "crap.wikimedia" t)
+
+         ;; Default.
          "mail.misc"))
 
+;;;--------------------------------------------------------------------------
+;;; Where we get mail from.
+
+;; Read mail on the IMAP server.
+(setq gnus-secondary-select-methods
+      `((nnimap "distorted"
+               (nnimap-address "mail.distorted.org.uk")
+               (nnimap-user "mdw")
+               (nnimap-stream starttls)
+               (nnimap-inbox ("INBOX" "to.split"))
+               (nnimap-split-methods nnimap-split-fancy)
+               (nnimap-split-fancy ,nnmail-split-fancy)
+               (nnimap-unsplittable-articles (%Deleted)))
+       (nnimap "markw-distorted"
+               (nnimap-address "mail.distorted.org.uk")
+               (nnimap-user "markw")
+               (nnimap-stream starttls)
+               (nnimap-inbox ("INBOX" "to.split"))
+               (nnimap-split-methods nnimap-split-fancy)
+               (nnimap-split-fancy ,nnmail-split-fancy)
+               (nnimap-unsplittable-articles (%Deleted)))
+       (nnimap "mdw-chiark"
+               (nnimap-address "imap.dovecot.chiark.greenend.org.uk")
+               (nnimap-user "mdw")
+               (nnimap-stream starttls)
+               (nnimap-inbox ("INBOX" "to.split"))
+               (nnimap-split-methods nnimap-split-fancy)
+               (nnimap-split-fancy ,nnmail-split-fancy)
+               (nnimap-unsplittable-articles (%Deleted)))
+       (nnimap "mwooding-chiark"
+               (nnimap-address "imap.dovecot.chiark.greenend.org.uk")
+               (nnimap-user "mwooding")
+               (nnimap-stream starttls)
+               (nnimap-inbox ("INBOX" "to.split"))
+               (nnimap-split-methods nnimap-split-fancy)
+               (nnimap-split-fancy ,nnmail-split-fancy)
+               (nnimap-unsplittable-articles (%Deleted)))
+       (nnimap "google"
+               (nnimap-address "imap.gmail.com")
+               (nnimap-stream tls)
+               (nnimap-inbox ("INBOX" "to.split"))
+               (nnimap-split-methods nnimap-split-fancy)
+               (nnimap-split-fancy ,nnmail-split-fancy)
+               (nnimap-unsplittable-articles (%Deleted)))))
+
+;; Send sent mail back to me.
+(setq gnus-message-archive-method "mail"
+      gnus-gcc-mark-as-read t
+      gnus-message-archive-group "nnimap+distorted:mail.sent")
+
 ;;;----- That's all, folks --------------------------------------------------