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