Update 5 drones
[~bandali/configs] / lisp / bandali-gnus.el
1 ;;; bandali-gnus.el --- bandali's Gnus setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2020 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: mail, news
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; My trusty super awesome Gnus setup.
24
25 ;;; Code:
26
27 (defvar b/maildir (expand-file-name "~/mail/"))
28 (with-eval-after-load 'recentf
29 (add-to-list 'recentf-exclude b/maildir))
30
31 (defvar b/gnus-init-file (b/etc "gnus"))
32
33 (eval-when-compile
34 (progn
35 (defvar nndraft-directory)
36 (defvar gnus-read-newsrc-file)
37 (defvar gnus-save-newsrc-file)
38 (defvar gnus-gcc-mark-as-read)
39 (defvar nnmail-split-abbrev-alist)))
40
41 (declare-function article-make-date-line "gnus-art" (date type))
42
43 (setq
44 mail-user-agent 'gnus-user-agent
45 read-mail-command 'gnus)
46
47 (use-package gnus
48 :bind (("s-m" . gnus-plugged)
49 ("s-M" . gnus-unplugged)
50 ("C-c a m" . gnus-plugged)
51 ("C-c a M" . gnus-unplugged))
52 :init
53 (setq
54 gnus-select-method '(nnnil "")
55 gnus-secondary-select-methods
56 '((nnimap "shemshak"
57 (nnimap-stream plain)
58 (nnimap-address "127.0.0.1")
59 (nnimap-server-port 143)
60 (nnimap-authenticator plain)
61 (nnimap-user "bandali@shemshak.local"))
62 (nnimap "gnu"
63 (nnimap-stream plain)
64 (nnimap-address "127.0.0.1")
65 (nnimap-server-port 143)
66 (nnimap-authenticator plain)
67 (nnimap-user "bandali@gnu.local")
68 (nnimap-inbox "INBOX")
69 (nnimap-split-methods 'nnimap-split-fancy)
70 (nnimap-split-fancy (|
71 ;; (: gnus-registry-split-fancy-with-parent)
72 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
73 ;; keep debbugs emails in INBOX
74 (list ".*<\\(.*\\)\\.debbugs\\.gnu\\.org>.*" "INBOX")
75 ;; gnu
76 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
77 ;; gnus
78 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
79 ;; libreplanet
80 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
81 ;; iana (e.g. tz-announce)
82 (list ".*<\\(.*\\)\\.iana\\.org>.*" "l.\\1")
83 ;; *.lists.sr.ht, omitting one dot if present
84 ;; add more \\.?\\([^.]*\\) if needed
85 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
86 ;; webmasters
87 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
88 ;; other
89 (list ".*atreus.freelists.org" "l.atreus")
90 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
91 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
92 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
93 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
94 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
95 ;; ----------------------------------
96 ;; legend: (u)nsubscribed | (d)ead
97 ;; ----------------------------------
98 ;; spam
99 ("X-Spam_action" "reject" "Junk")
100 ;; otherwise, leave mail in INBOX
101 "INBOX")))
102 (nnimap "uwaterloo"
103 (nnimap-stream plain)
104 (nnimap-address "127.0.0.1")
105 (nnimap-server-port 143)
106 (nnimap-authenticator plain)
107 (nnimap-user "abandali@uwaterloo.local")
108 (nnimap-inbox "INBOX")
109 (nnimap-split-methods 'nnimap-split-fancy)
110 (nnimap-split-fancy (|
111 ;; (: gnus-registry-split-fancy-with-parent)
112 ;; se212-f19
113 ("subject" "SE\\s-?212" "course.se212-f19")
114 (from "SE\\s-?212" "course.se212-f19")
115 ;; catch-all
116 "INBOX")))
117 (nnimap "csc"
118 (nnimap-stream plain)
119 (nnimap-address "127.0.0.1")
120 (nnimap-server-port 143)
121 (nnimap-authenticator plain)
122 (nnimap-user "abandali@csclub.uwaterloo.local")
123 (nnimap-inbox "INBOX")
124 (nnimap-split-methods 'nnimap-split-fancy)
125 (nnimap-split-fancy (|
126 ;; cron reports and other messages from root
127 (from "root@\\(.*\\.\\)?csclub\\.uwaterloo\\.ca" "INBOX")
128 ;; spam
129 ("X-Spam-Flag" "YES" "Junk")
130 ;; catch-all
131 "INBOX"))))
132 gnus-message-archive-group "nnimap+gnu:INBOX"
133 gnus-parameters
134 '(("l\\.atreus"
135 (to-address . "atreus@freelists.org")
136 (to-list . "atreus@freelists.org"))
137 ("l\\.deepspec"
138 (to-address . "deepspec@lists.cs.princeton.edu")
139 (to-list . "deepspec@lists.cs.princeton.edu")
140 (list-identifier . "\\[deepspec\\]"))
141 ("l\\.emacs-devel"
142 (to-address . "emacs-devel@gnu.org")
143 (to-list . "emacs-devel@gnu.org"))
144 ("l\\.help-gnu-emacs"
145 (to-address . "help-gnu-emacs@gnu.org")
146 (to-list . "help-gnu-emacs@gnu.org"))
147 ("l\\.info-gnu-emacs"
148 (to-address . "info-gnu-emacs@gnu.org")
149 (to-list . "info-gnu-emacs@gnu.org"))
150 ("l\\.emacs-orgmode"
151 (to-address . "emacs-orgmode@gnu.org")
152 (to-list . "emacs-orgmode@gnu.org")
153 (list-identifier . "\\[O\\]"))
154 ("l\\.emacs-tangents"
155 (to-address . "emacs-tangents@gnu.org")
156 (to-list . "emacs-tangents@gnu.org"))
157 ("l\\.emacsconf-committee"
158 (to-address . "emacsconf-committee@gnu.org")
159 (to-list . "emacsconf-committee@gnu.org"))
160 ("l\\.emacsconf-discuss"
161 (to-address . "emacsconf-discuss@gnu.org")
162 (to-list . "emacsconf-discuss@gnu.org"))
163 ("l\\.emacsconf-register"
164 (to-address . "emacsconf-register@gnu.org")
165 (to-list . "emacsconf-register@gnu.org"))
166 ("l\\.emacsconf-submit"
167 (to-address . "emacsconf-submit@gnu.org")
168 (to-list . "emacsconf-submit@gnu.org"))
169 ("l\\.fencepost-users"
170 (to-address . "fencepost-users@gnu.org")
171 (to-list . "fencepost-users@gnu.org")
172 (list-identifier . "\\[Fencepost-users\\]"))
173 ("l\\.gnewsense-art"
174 (to-address . "gnewsense-art@nongnu.org")
175 (to-list . "gnewsense-art@nongnu.org")
176 (list-identifier . "\\[gNewSense-art\\]"))
177 ("l\\.gnewsense-dev"
178 (to-address . "gnewsense-dev@nongnu.org")
179 (to-list . "gnewsense-dev@nongnu.org")
180 (list-identifier . "\\[Gnewsense-dev\\]"))
181 ("l\\.gnewsense-users"
182 (to-address . "gnewsense-users@nongnu.org")
183 (to-list . "gnewsense-users@nongnu.org")
184 (list-identifier . "\\[gNewSense-users\\]"))
185 ("l\\.gnunet-developers"
186 (to-address . "gnunet-developers@gnu.org")
187 (to-list . "gnunet-developers@gnu.org")
188 (list-identifier . "\\[GNUnet-developers\\]"))
189 ("l\\.help-gnunet"
190 (to-address . "help-gnunet@gnu.org")
191 (to-list . "help-gnunet@gnu.org")
192 (list-identifier . "\\[Help-gnunet\\]"))
193 ("l\\.bug-gnuzilla"
194 (to-address . "bug-gnuzilla@gnu.org")
195 (to-list . "bug-gnuzilla@gnu.org")
196 (list-identifier . "\\[Bug-gnuzilla\\]"))
197 ("l\\.gnuzilla-dev"
198 (to-address . "gnuzilla-dev@gnu.org")
199 (to-list . "gnuzilla-dev@gnu.org")
200 (list-identifier . "\\[Gnuzilla-dev\\]"))
201 ("l\\.guile-devel"
202 (to-address . "guile-devel@gnu.org")
203 (to-list . "guile-devel@gnu.org"))
204 ("l\\.guile-user"
205 (to-address . "guile-user@gnu.org")
206 (to-list . "guile-user@gnu.org"))
207 ("l\\.guix-devel"
208 (to-address . "guix-devel@gnu.org")
209 (to-list . "guix-devel@gnu.org"))
210 ("l\\.help-guix"
211 (to-address . "help-guix@gnu.org")
212 (to-list . "help-guix@gnu.org"))
213 ("l\\.info-guix"
214 (to-address . "info-guix@gnu.org")
215 (to-list . "info-guix@gnu.org"))
216 ("l\\.savannah-hackers-public"
217 (to-address . "savannah-hackers-public@gnu.org")
218 (to-list . "savannah-hackers-public@gnu.org"))
219 ("l\\.savannah-users"
220 (to-address . "savannah-users@gnu.org")
221 (to-list . "savannah-users@gnu.org"))
222 ("l\\.www-commits"
223 (to-address . "www-commits@gnu.org")
224 (to-list . "www-commits@gnu.org"))
225 ("l\\.www-discuss"
226 (to-address . "www-discuss@gnu.org")
227 (to-list . "www-discuss@gnu.org"))
228 ("l\\.haskell-art"
229 (to-address . "haskell-art@we.lurk.org")
230 (to-list . "haskell-art@we.lurk.org")
231 (list-identifier . "\\[haskell-art\\]"))
232 ("l\\.haskell-cafe"
233 (to-address . "haskell-cafe@haskell.org")
234 (to-list . "haskell-cafe@haskell.org")
235 (list-identifier . "\\[Haskell-cafe\\]"))
236 ("l\\.notmuch"
237 (to-address . "notmuch@notmuchmail.org")
238 (to-list . "notmuch@notmuchmail.org"))
239 ("l\\.parabola-dev"
240 (to-address . "dev@lists.parabola.nu")
241 (to-list . "dev@lists.parabola.nu")
242 (list-identifier . "\\[Dev\\]"))
243 ("l\\.~bandali\\.public-inbox"
244 (to-address . "~bandali/public-inbox@lists.sr.ht")
245 (to-list . "~bandali/public-inbox@lists.sr.ht"))
246 ("l\\.~sircmpwn\\.free-writers-club"
247 (to-address . "~sircmpwn/free-writers-club@lists.sr.ht")
248 (to-list . "~sircmpwn/free-writers-club@lists.sr.ht"))
249 ("l\\.~sircmpwn\\.srht-admins"
250 (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht")
251 (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht"))
252 ("l\\.~sircmpwn\\.srht-announce"
253 (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht")
254 (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht"))
255 ("l\\.~sircmpwn\\.srht-dev"
256 (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht")
257 (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht"))
258 ("l\\.~sircmpwn\\.srht-discuss"
259 (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht")
260 (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht"))
261 ("webmasters"
262 (to-address . "webmasters@gnu.org")
263 (to-list . "webmasters@gnu.org"))
264 ("gnu.*"
265 (gcc-self . t))
266 ("l\\."
267 (subscribed . t))
268 ("nnimap\\+uwaterloo:.*"
269 (gcc-self . t)))
270 gnus-large-newsgroup 50
271 gnus-home-directory (b/var "gnus/")
272 gnus-directory (concat gnus-home-directory "news/")
273 message-directory (concat gnus-home-directory "mail/")
274 nndraft-directory (concat gnus-home-directory "drafts/")
275 gnus-save-newsrc-file nil
276 gnus-read-newsrc-file nil
277 gnus-interactive-exit nil
278 gnus-gcc-mark-as-read t)
279 :config
280 (when (version< emacs-version "27")
281 (with-eval-after-load 'nnmail
282 (add-to-list
283 'nnmail-split-abbrev-alist
284 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
285 t)))
286
287 ;; (require 'gnus-registry)
288 ;; (setq gnus-registry-max-entries 2500)
289 ;; (setq gnus-registry-ignored-groups
290 ;; (append gnus-registry-ignored-groups
291 ;; '(("^nnimap:gnu\\.l" t)
292 ;; ("webmasters$" t))))
293 ;; (gnus-registry-initialize)
294
295 (with-eval-after-load 'recentf
296 (add-to-list 'recentf-exclude gnus-home-directory)))
297
298 (use-package gnus-art
299 :config
300 (setq
301 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
302 gnus-sorted-header-list '("^From:"
303 "^X-RT-Originator"
304 "^Newsgroups:"
305 "^Subject:"
306 "^Date:"
307 "^Envelope-To:"
308 "^Followup-To:"
309 "^Reply-To:"
310 "^Organization:"
311 "^Summary:"
312 "^Abstract:"
313 "^Keywords:"
314 "^To:"
315 "^[BGF]?Cc:"
316 "^Posted-To:"
317 "^Mail-Copies-To:"
318 "^Mail-Followup-To:"
319 "^Apparently-To:"
320 "^Resent-From:"
321 "^User-Agent:"
322 "^X-detected-operating-system:"
323 "^X-Spam_action:"
324 "^X-Spam_bar:"
325 "^Message-ID:"
326 ;; "^References:"
327 "^List-Id:"
328 "^Gnus-Warning:")
329 gnus-visible-headers (mapconcat 'identity
330 gnus-sorted-header-list
331 "\\|")
332 ;; local-lapsed article dates
333 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
334 gnus-article-date-headers '(user-defined)
335 gnus-article-time-format
336 (lambda (time)
337 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
338 (local (article-make-date-line date 'local))
339 (combined-lapsed (article-make-date-line date
340 'combined-lapsed))
341 (lapsed (progn
342 (string-match " (.+" combined-lapsed)
343 (match-string 0 combined-lapsed))))
344 (concat local lapsed))))
345 (bind-keys
346 :map gnus-article-mode-map
347 ("M-L" . org-store-link)))
348
349 (use-package gnus-sum
350 :bind (:map gnus-summary-mode-map
351 :prefix-map b/gnus-summary-prefix-map
352 :prefix "v"
353 ("r" . gnus-summary-reply)
354 ("w" . gnus-summary-wide-reply)
355 ("v" . gnus-summary-show-raw-article))
356 :config
357 (bind-keys
358 :map gnus-summary-mode-map
359 ("M-L" . org-store-link))
360 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
361 :custom
362 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
363 gnus-thread-sort-by-subject
364 gnus-thread-sort-by-date)))
365
366 (use-package gnus-msg
367 :config
368 (defvar b/shemshak-signature "Amin Bandali
369 https://shemshak.org/~bandali")
370 (defvar b/uwaterloo-signature "Amin Bandali, MMath
371 Cheriton School of Computer Science
372 University of Waterloo
373 https://bndl.org")
374 (defvar b/csc-signature "Amin Bandali | https://bndl.org
375 System Administrator, Systems Committee
376 Computer Science Club, University of Waterloo")
377 (setq gnus-message-replysign t
378 gnus-posting-styles
379 '((".*"
380 (address "bandali@gnu.org"))
381 ("nnimap\\+gnu:l\\..*"
382 (signature nil))
383 ("nnimap\\+gnu:.*"
384 (organization "GNU"))
385 ((header "subject" "ThankCRM")
386 (to "webmasters-comment@gnu.org")
387 (body "")
388 (eval (setq b/message-cite-say-hi nil)))
389 ("nnimap\\+shemshak:.*"
390 (address "amin@shemshak.org")
391 (body "\nBest,\n")
392 (signature b/shemshak-signature)
393 (gcc "nnimap+shemshak:Sent")
394 (eval (setq b/message-cite-say-hi t)))
395 ("nnimap\\+uwaterloo:.*"
396 (address "bandali@uwaterloo.ca")
397 (body "\nBest,\n")
398 (signature b/uwaterloo-signature))
399 ("nnimap\\+uwaterloo:INBOX"
400 (gcc "\"nnimap+uwaterloo:Sent Items\""))
401 ("nnimap\\+csc:.*"
402 (address "bandali@csclub.uwaterloo.ca")
403 (signature b/csc-signature)
404 (gcc "nnimap+csc:Sent"))))
405 :hook (gnus-message-setup . (lambda ()
406 (unless (mml-secure-is-encrypted-p)
407 (mml-secure-message-sign)))))
408
409 (use-package gnus-topic
410 :hook (gnus-group-mode . gnus-topic-mode)
411 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
412
413 (use-package gnus-agent
414 :config
415 (setq gnus-agent-synchronize-flags 'ask)
416 :hook (gnus-group-mode . gnus-agent-mode))
417
418 (use-package gnus-group
419 :config
420 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
421
422 (comment
423 ;; problematic with ebdb's popup, *EBDB-Gnus*
424 (use-package gnus-win
425 :config
426 (setq gnus-use-full-window nil)))
427
428 (use-package gnus-dired
429 :commands gnus-dired-mode
430 :init
431 (add-hook 'dired-mode-hook 'gnus-dired-mode))
432
433 (comment
434 (use-package gnus-utils
435 :custom
436 (gnus-completing-read-function 'gnus-ido-completing-read)))
437
438 (use-package mm-decode
439 :config
440 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
441 mm-decrypt-option 'known
442 mm-verify-option 'known))
443
444 (use-package mm-uu
445 :config
446 (when (version< "27" emacs-version)
447 (set-face-attribute 'mm-uu-extract nil :extend t))
448 :custom
449 (mm-uu-diff-groups-regexp
450 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
451
452 (use-package mml)
453
454 (use-package mml-sec
455 :custom
456 (mml-secure-openpgp-encrypt-to-self t)
457 (mml-secure-openpgp-sign-with-sender t))
458
459 (use-package gnus-article-treat-patch
460 :disabled
461 :demand
462 :load-path "lisp/"
463 :config
464 ;; note: be sure to customize faces with `:foreground "white"' when
465 ;; using a theme with a white/light background :)
466 (setq ft/gnus-article-patch-conditions
467 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
468
469 (provide 'bandali-gnus)
470 ;;; bandali-gnus.el ends here