* init.el(b/duplicate-line-or-region): New convenience function.
[~bandali/configs] / lisp / bandali-gnus.el
... / ...
CommitLineData
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 "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 ;; ----------------------------------
94 ;; spam
95 ("X-Spam-Flag" "YES" "Junk")
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
274 ;; (gnus-registry-initialize)
275
276 (with-eval-after-load 'recentf
277 (add-to-list 'recentf-exclude gnus-home-directory)))
278
279(use-package gnus-art
280 :config
281 (setq
282 gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)")
283 gnus-sorted-header-list '("^From:"
284 "^X-RT-Originator"
285 "^Newsgroups:"
286 "^Subject:"
287 "^Date:"
288 "^Envelope-To:"
289 "^Followup-To:"
290 "^Reply-To:"
291 "^Organization:"
292 "^Summary:"
293 "^Abstract:"
294 "^Keywords:"
295 "^To:"
296 "^[BGF]?Cc:"
297 "^Posted-To:"
298 "^Mail-Copies-To:"
299 "^Mail-Followup-To:"
300 "^Apparently-To:"
301 "^Resent-From:"
302 "^User-Agent:"
303 "^X-detected-operating-system:"
304 "^X-Spam-Flag:"
305 "^X-Spam-Level:"
306 "^Message-ID:"
307 ;; "^References:"
308 "^List-Id:"
309 "^Gnus-Warning:")
310 gnus-visible-headers (mapconcat 'identity
311 gnus-sorted-header-list
312 "\\|")
313 ;; local-lapsed article dates
314 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
315 gnus-article-date-headers '(user-defined)
316 gnus-article-time-format
317 (lambda (time)
318 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
319 (local (article-make-date-line date 'local))
320 (combined-lapsed (article-make-date-line date
321 'combined-lapsed))
322 (lapsed (progn
323 (string-match " (.+" combined-lapsed)
324 (match-string 0 combined-lapsed))))
325 (concat local lapsed))))
326 (bind-keys
327 :map gnus-article-mode-map
328 ("M-L" . org-store-link)))
329
330(use-package gnus-sum
331 :bind (:map gnus-summary-mode-map
332 :prefix-map b/gnus-summary-prefix-map
333 :prefix "v"
334 ("r" . gnus-summary-reply)
335 ("w" . gnus-summary-wide-reply)
336 ("v" . gnus-summary-show-raw-article))
337 :config
338 (bind-keys
339 :map gnus-summary-mode-map
340 ("M-L" . org-store-link))
341 :hook (gnus-summary-mode . b/no-mouse-autoselect-window)
342 :custom
343 (gnus-thread-sort-functions '(gnus-thread-sort-by-number
344 gnus-thread-sort-by-subject
345 gnus-thread-sort-by-date)))
346
347(use-package gnus-msg
348 :config
349 (defvar b/shemshak-signature "Amin Bandali
350https://shemshak.org/~amin")
351 (defvar b/uw-signature "Amin Bandali, MMath Student
352Cheriton School of Computer Science
353University of Waterloo
354https://bandali.eu.org")
355 (defvar b/csc-signature "Amin Bandali
356System Administrator, Systems Committee
357Computer Science Club, University of Waterloo
358https://csclub.uwaterloo.ca/~abandali")
359 (setq gnus-message-replysign t
360 gnus-posting-styles
361 '((".*"
362 (address "bandali@gnu.org"))
363 ("nnimap\\+gnu:l\\..*"
364 (signature nil))
365 ("nnimap\\+gnu:.*"
366 (organization "GNU"))
367 ((header "subject" "ThankCRM")
368 (to "webmasters-comment@gnu.org")
369 (body "")
370 (eval (setq b/message-cite-say-hi nil)))
371 ("nnimap\\+shemshak:.*"
372 (address "amin@shemshak.org")
373 (body "\nBest,\n")
374 (signature b/shemshak-signature)
375 (gcc "nnimap+shemshak:Sent")
376 (eval (setq b/message-cite-say-hi t)))
377 ("nnimap\\+uw:.*"
378 (address "bandali@uwaterloo.ca")
379 (body "\nBest,\n")
380 (signature b/uw-signature))
381 ("nnimap\\+uw:INBOX"
382 (gcc "\"nnimap+uw:Sent Items\""))
383 ("nnimap\\+csc:.*"
384 (address "bandali@csclub.uwaterloo.ca")
385 (signature b/csc-signature)
386 (gcc "nnimap+csc:Sent"))))
387 :hook (gnus-message-setup . (lambda ()
388 (unless (mml-secure-is-encrypted-p)
389 (mml-secure-message-sign)))))
390
391(use-package gnus-topic
392 :hook (gnus-group-mode . gnus-topic-mode)
393 :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"))
394
395(use-package gnus-agent
396 :config
397 (setq gnus-agent-synchronize-flags 'ask)
398 :hook (gnus-group-mode . gnus-agent-mode))
399
400(use-package gnus-group
401 :config
402 (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)"))
403
404(comment
405 ;; problematic with ebdb's popup, *EBDB-Gnus*
406 (use-package gnus-win
407 :config
408 (setq gnus-use-full-window nil)))
409
410(use-package gnus-dired
411 :commands gnus-dired-mode
412 :init
413 (add-hook 'dired-mode-hook 'gnus-dired-mode))
414
415(comment
416 (use-package gnus-utils
417 :custom
418 (gnus-completing-read-function 'gnus-ido-completing-read)))
419
420(use-package mm-decode
421 :config
422 (setq mm-discouraged-alternatives '("text/html" "text/richtext")
423 mm-decrypt-option 'known
424 mm-verify-option 'known))
425
426(use-package mm-uu
427 :config
428 (when (version< "27" emacs-version)
429 (set-face-attribute 'mm-uu-extract nil :extend t))
430 :custom
431 (mm-uu-diff-groups-regexp
432 "\\(gmane\\|gnu\\|l\\)\\..*\\(diff\\|commit\\|cvs\\|bug\\|dev\\)"))
433
434(use-package mml)
435
436(use-package mml-sec
437 :custom
438 (mml-secure-openpgp-encrypt-to-self t)
439 (mml-secure-openpgp-sign-with-sender t))
440
441(use-package gnus-article-treat-patch
442 :disabled
443 :demand
444 :load-path "lisp/"
445 :config
446 ;; note: be sure to customize faces with `:foreground "white"' when
447 ;; using a theme with a white/light background :)
448 (setq ft/gnus-article-patch-conditions
449 '("^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")))
450
451(provide 'bandali-gnus)
452;;; bandali-gnus.el ends here