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