Add picom config
[~bandali/configs] / .emacs.d / 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 (csetq
44 mail-user-agent 'gnus-user-agent
45 read-mail-command 'gnus
46
47 gnus-select-method '(nnnil "")
48 gnus-secondary-select-methods
49 '((nnimap "shemshak"
50 (nnimap-stream plain)
51 (nnimap-address "127.0.0.1")
52 (nnimap-server-port 143)
53 (nnimap-authenticator plain)
54 (nnimap-user "bandali@shemshak.local"))
55 (nnimap "gnu"
56 (nnimap-stream plain)
57 (nnimap-address "127.0.0.1")
58 (nnimap-server-port 143)
59 (nnimap-authenticator plain)
60 (nnimap-user "bandali@gnu.local")
61 (nnimap-inbox "INBOX")
62 (nnimap-split-methods 'nnimap-split-fancy)
63 (nnimap-split-fancy (|
64 ;; (: gnus-registry-split-fancy-with-parent)
65 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
66 ;; keep debbugs emails in INBOX
67 (list ".*<\\(.*\\)\\.debbugs\\.gnu\\.org>.*" "INBOX")
68 ;; list moderation emails
69 (from ".+-\\(owner\\|bounces\\)@\\(non\\)?gnu\\.org" "listmod")
70 ;; gnu
71 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
72 ;; gnus
73 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
74 ;; libreplanet
75 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
76 ;; iana (e.g. tz-announce)
77 (list ".*<\\(.*\\)\\.iana\\.org>.*" "l.\\1")
78 ;; orbitalfox (e.g. gemini)
79 (list ".*<\\(.*\\)\\.lists\\.orbitalfox\\.eu>.*" "l.\\1")
80 ;; haskell
81 (list ".*<\\(.*\\)\\.haskell\\.org>.*" "l.\\1")
82 ;; *.lists.sr.ht, omitting one dot if present
83 ;; add more \\.?\\([^.]*\\) if needed
84 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists\\.sr\\.ht>.*" "l.~\\1.\\2\\3")
85 ;; webmasters
86 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
87 ;; other
88 (list ".*atreus.freelists.org" "l.atreus")
89 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
90 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
91 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
92 (list ".*dev.lists.parabola.nu" "l.parabola-dev")
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 ;; cron reports and other messages from root
125 (from "root@\\(.*\\.\\)?csclub\\.uwaterloo\\.ca" "INBOX")
126 ;; spam
127 ("X-Spam-Flag" "YES" "Junk")
128 ;; catch-all
129 "INBOX")))
130 (nnimap "sfl"
131 (nnimap-stream tls)
132 (nnimap-address "mail.savoirfairelinux.com")
133 (nnimap-user "amin.bandali")))
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"))
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"))
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))
276 ("nnimap\\+uwaterloo:.*"
277 (gcc-self . t)))
278 ;; nnimap-record-commands t
279 gnus-large-newsgroup 50
280 gnus-home-directory (b/var "gnus/")
281 gnus-directory (concat gnus-home-directory "news/")
282 message-directory (concat gnus-home-directory "mail/")
283 nndraft-directory (concat gnus-home-directory "drafts/")
284 gnus-save-newsrc-file nil
285 gnus-read-newsrc-file nil
286 gnus-search-use-parsed-queries t
287 gnus-interactive-exit nil
288 gnus-gcc-mark-as-read t)
289
290 (with-eval-after-load 'gnus
291 (when (version< emacs-version "27")
292 (with-eval-after-load 'nnmail
293 (add-to-list
294 'nnmail-split-abbrev-alist
295 '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
296 t)))
297
298 ;; (require 'gnus-registry)
299 ;; (setq gnus-registry-max-entries 2500)
300 ;; (setq gnus-registry-ignored-groups
301 ;; (append gnus-registry-ignored-groups
302 ;; '(("^nnimap:gnu\\.l" t)
303 ;; ("webmasters$" t))))
304 ;; (gnus-registry-initialize)
305
306 (with-eval-after-load 'recentf
307 (add-to-list 'recentf-exclude gnus-home-directory))
308
309 ;; hooks
310 (add-hook 'gnus-group-mode-hook #'gnus-topic-mode)
311 (add-hook 'gnus-group-mode-hook #'gnus-agent-mode))
312 ;; global key bindings
313 (global-set-key (kbd "s-m") #'gnus-plugged)
314 (global-set-key (kbd "s-M") #'gnus-unplugged)
315 (global-set-key (kbd "C-c m") #'gnus-plugged)
316 (global-set-key (kbd "C-c M") #'gnus-unplugged)
317
318 (with-eval-after-load 'gnus-art
319 (csetq
320 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
321 gnus-sorted-header-list '("^From:"
322 "^X-RT-Originator"
323 "^Newsgroups:"
324 "^Subject:"
325 "^Date:"
326 "^Envelope-To:"
327 "^Followup-To:"
328 "^Reply-To:"
329 "^Organization:"
330 "^Summary:"
331 "^Abstract:"
332 "^Keywords:"
333 "^To:"
334 "^[BGF]?Cc:"
335 "^Posted-To:"
336 "^Mail-Copies-To:"
337 "^Mail-Followup-To:"
338 "^Apparently-To:"
339 "^Resent-From:"
340 "^User-Agent:"
341 "^X-detected-operating-system:"
342 "^X-Spam_action:"
343 "^X-Spam_bar:"
344 "^Message-ID:"
345 ;; "^References:"
346 "^List-Id:"
347 "^Gnus-Warning:")
348 gnus-visible-headers (mapconcat 'identity
349 gnus-sorted-header-list
350 "\\|")
351 ;; local-lapsed article dates
352 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
353 gnus-article-date-headers '(user-defined)
354 gnus-article-time-format
355 (lambda (time)
356 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
357 (local (article-make-date-line date 'local))
358 (combined-lapsed (article-make-date-line date
359 'combined-lapsed))
360 (lapsed (progn
361 (string-match " (.+" combined-lapsed)
362 (match-string 0 combined-lapsed))))
363 (concat local lapsed))))
364 ;; local key bindings
365 (define-key gnus-article-mode-map (kbd "M-L") #'org-store-link))
366
367 (with-eval-after-load 'gnus-sum
368 (csetq gnus-thread-sort-functions '(gnus-thread-sort-by-number
369 gnus-thread-sort-by-subject
370 gnus-thread-sort-by-date))
371 ;; local key bindings
372 (define-key gnus-summary-mode-map (kbd "M-L") #'org-store-link)
373 (defvar b/gnus-summary-prefix-map)
374 (define-prefix-command 'b/gnus-summary-prefix-map)
375 (define-key gnus-summary-mode-map (kbd "v")
376 'b/gnus-summary-prefix-map)
377 (define-key b/gnus-summary-prefix-map (kbd "r")
378 #'gnus-summary-reply)
379 (define-key b/gnus-summary-prefix-map (kbd "w")
380 #'gnus-summary-wide-reply)
381 (define-key b/gnus-summary-prefix-map (kbd "v")
382 #'gnus-summary-show-raw-article))
383 ;; hooks
384 (add-hook 'gnus-summary-mode-hook #'b/no-mouse-autoselect-window)
385
386 (defvar b/sfl-p nil)
387 (with-eval-after-load 'gnus-msg
388 (defvar b/shemshak-signature "Amin Bandali
389 https://shemshak.org/~bandali")
390 (defvar b/uwaterloo-signature "Amin Bandali, MMath
391 https://bndl.org")
392 (defvar b/csc-signature "Amin Bandali (https://bndl.org)
393 Systems Committee <syscom@csclub.uwaterloo.ca>
394 Computer Science Club of the University of Waterloo")
395 (defvar b/sfl-signature "Amin Bandali
396 Free Software Consultant
397 Savoir-faire Linux
398 GNU Jami: bandali")
399 (csetq
400 gnus-message-replysign t
401 gnus-posting-styles
402 '((".*"
403 (address "bandali@gnu.org"))
404 ("nnimap\\+gnu:l\\..*"
405 (signature nil))
406 ("nnimap\\+gnu:.*"
407 (organization "GNU"))
408 ((header "subject" "ThankCRM")
409 (to "webmasters-comment@gnu.org")
410 (body "")
411 (eval (setq b/message-cite-say-hi nil)))
412 ("nnimap\\+shemshak:.*"
413 (address "amin@shemshak.org")
414 (body "\nBest,\n")
415 (signature b/shemshak-signature)
416 (gcc "nnimap+shemshak:Sent")
417 (eval (setq b/message-cite-say-hi t)))
418 ("nnimap\\+uwaterloo:.*"
419 (address "bandali@uwaterloo.ca")
420 (body "\nBest,\n")
421 (signature b/uwaterloo-signature))
422 ("nnimap\\+uwaterloo:INBOX"
423 (gcc "\"nnimap+uwaterloo:Sent Items\""))
424 ("nnimap\\+csc:.*"
425 (address "bandali@csclub.uwaterloo.ca")
426 (signature b/csc-signature)
427 (gcc "nnimap+csc:Sent"))
428 ("nnimap\\+sfl:.*"
429 (address "amin.bandali@savoirfairelinux.com")
430 (signature b/sfl-signature)
431 (gcc "nnimap+sfl:Sent")
432 (eval (setq-local b/sfl-p t))))))
433 ;; hooks
434 (with-eval-after-load 'gnus
435 (add-hook 'gnus-message-setup-hook
436 (lambda ()
437 (unless (or (mml-secure-is-encrypted-p)
438 b/sfl-p)
439 (mml-secure-message-sign)))))
440
441 (with-eval-after-load 'gnus-topic
442 (csetq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
443
444 (with-eval-after-load 'gnus-agent
445 (csetq gnus-agent-synchronize-flags 'ask))
446
447 (with-eval-after-load 'gnus-group
448 (csetq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
449
450 ;; problematic with ebdb's popup, *EBDB-Gnus*
451 ;; (with-eval-after-load 'gnus-win
452 ;; (csetq gnus-use-full-window nil))
453
454 (with-eval-after-load 'gnus-dired
455 (add-hook 'dired-mode-hook 'gnus-dired-mode))
456
457 ;; (with-eval-after-load 'gnus-utils
458 ;; (csetq gnus-completing-read-function 'gnus-ido-completing-read))
459
460 (with-eval-after-load 'mm-decode
461 (csetq mm-discouraged-alternatives '("text/html" "text/richtext")
462 mm-decrypt-option 'known
463 mm-verify-option 'known))
464
465 (with-eval-after-load 'mm-uu
466 (when (version< "27" emacs-version)
467 (set-face-attribute 'mm-uu-extract nil :extend t))
468 (when (version< emacs-version "27")
469 (csetq mm-uu-diff-groups-regexp ".")))
470
471 (with-eval-after-load 'mml-sec
472 (csetq mml-secure-openpgp-encrypt-to-self t
473 mml-secure-openpgp-sign-with-sender t))
474
475 ;; (require 'gnus-article-treat-patch)
476 ;; ;; note: be sure to customize faces with `:foreground "white"' when
477 ;; ;; using a theme with a white/light background :)
478 ;; (setq ft/gnus-article-patch-conditions
479 ;; '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@"))
480
481 (provide 'bandali-gnus)
482 ;;; bandali-gnus.el ends here