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