1 ;;; bandali-gnus.el --- bandali's Gnus setup -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2021 Amin Bandali
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: mail, news
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.
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.
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/>.
23 ;; My trusty super awesome Gnus setup.
27 (defvar b
/maildir
(expand-file-name "~/mail/"))
28 (with-eval-after-load 'recentf
29 (add-to-list 'recentf-exclude b
/maildir
))
31 (defvar b
/gnus-init-file
(b/etc
"gnus"))
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
)))
41 (declare-function article-make-date-line
"gnus-art" (date type
))
44 mail-user-agent
'gnus-user-agent
45 read-mail-command
'gnus
47 gnus-select-method
'(nnnil "")
48 gnus-secondary-select-methods
50 ((string= (system-name) "langa")
54 (nnimap-address "127.0.0.1")
55 (nnimap-server-port 143)
56 (nnimap-authenticator plain
)
57 (nnimap-user "bandali@shemshak.local"))
61 (nnimap-address "127.0.0.1")
62 (nnimap-server-port 143)
63 (nnimap-authenticator plain
)
64 (nnimap-user "bandali@gnu.local")
65 (nnimap-inbox "INBOX")
66 (nnimap-split-methods 'nnimap-split-fancy
)
69 ;; (: gnus-registry-split-fancy-with-parent)
70 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
71 ;; keep debbugs emails in INBOX
72 (list ".*<\\(.*\\)\\.debbugs\\.gnu\\.org>.*" "INBOX")
73 ;; list moderation emails
74 (from ".+-\\(owner\\|bounces\\)@\\(non\\)?gnu\\.org" "listmod")
76 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
78 (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
80 (list ".*<\\(.*\\)\\.libreplanet\\.org>.*" "l.\\1")
81 ;; iana (e.g. tz-announce)
82 (list ".*<\\(.*\\)\\.iana\\.org>.*" "l.\\1")
84 (list ".*<\\(.*\\)\\.haskell\\.org>.*" "l.\\1")
85 ;; *.lists.sr.ht, omitting one dot if present
86 ;; add more \\.?\\([^.]*\\) if needed
87 (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists\\.sr\\.ht>.*" "l.~\\1.\\2\\3")
89 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
91 ("subject" "nagios-fsf:.*" "nagios-fsf")
92 (list ".*atreus.freelists.org" "l.atreus")
93 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
94 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
95 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
96 (list ".*dev.lists.parabola.nu" "l.parabola-dev")
97 ;; ----------------------------------
98 ;; legend: (u)nsubscribed | (d)ead
99 ;; ----------------------------------
101 ("X-Spam_action" "reject" "Junk")
102 ;; otherwise, leave mail in INBOX
106 (nnimap-stream plain
)
107 (nnimap-address "127.0.0.1")
108 (nnimap-server-port 143)
109 (nnimap-authenticator plain
)
110 (nnimap-user "abandali@uwaterloo.local")
111 (nnimap-inbox "INBOX")
112 (nnimap-split-methods 'nnimap-split-fancy
)
115 ;; (: gnus-registry-split-fancy-with-parent)
117 ("subject" "SE\\s-?212" "course.se212-f19")
118 (from "SE\\s-?212" "course.se212-f19")
123 (nnimap-stream plain
)
124 (nnimap-address "127.0.0.1")
125 (nnimap-server-port 143)
126 (nnimap-authenticator plain
)
127 (nnimap-user "abandali@csclub.uwaterloo.local")
128 (nnimap-inbox "INBOX")
129 (nnimap-split-methods 'nnimap-split-fancy
)
132 ;; cron reports and other messages from root
133 (from "root@\\(.*\\.\\)?csclub\\.uwaterloo\\.ca" "INBOX")
135 ("X-Spam-Flag" "YES" "Junk")
138 ((string= (system-name) "jirud")
142 (nnimap-address "mail.savoirfairelinux.com")
143 (nnimap-user "amin.bandali"))))))
144 gnus-message-archive-group
"nnimap+gnu:INBOX"
147 (to-address .
"deepspec@lists.cs.princeton.edu")
148 (to-list .
"deepspec@lists.cs.princeton.edu")
149 (list-identifier .
"\\[deepspec\\]"))
150 ("l\\.fencepost-users"
151 (to-address .
"fencepost-users@gnu.org")
152 (to-list .
"fencepost-users@gnu.org")
153 (list-identifier .
"\\[Fencepost-users\\]"))
155 (to-address .
"haskell-cafe@haskell.org")
156 (to-list .
"haskell-cafe@haskell.org")
157 (list-identifier .
"\\[Haskell-cafe\\]"))
162 ("nnimap\\+uwaterloo:.*"
164 ;; nnimap-record-commands t
165 ;; gnus-large-newsgroup 50
166 ;; gnus-process-mark-toggle t
167 gnus-home-directory
(b/var
"gnus/")
168 gnus-directory
(concat gnus-home-directory
"news/")
169 message-directory
(concat gnus-home-directory
"mail/")
170 nndraft-directory
(concat gnus-home-directory
"drafts/")
171 gnus-save-newsrc-file nil
172 gnus-read-newsrc-file nil
173 gnus-search-use-parsed-queries t
174 gnus-interactive-exit nil
175 gnus-gcc-mark-as-read t
)
177 (with-eval-after-load 'gnus
178 (when (version< emacs-version
"27")
179 (with-eval-after-load 'nnmail
181 'nnmail-split-abbrev-alist
182 '(list .
"list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
185 ;; (require 'gnus-registry)
186 ;; (setq gnus-registry-max-entries 2500)
187 ;; (setq gnus-registry-ignored-groups
188 ;; (append gnus-registry-ignored-groups
189 ;; '(("^nnimap:gnu\\.l" t)
190 ;; ("webmasters$" t))))
191 ;; (gnus-registry-initialize)
193 (with-eval-after-load 'recentf
194 (add-to-list 'recentf-exclude gnus-home-directory
))
197 (add-hook 'gnus-group-mode-hook
#'gnus-topic-mode
)
198 (add-hook 'gnus-group-mode-hook
#'gnus-agent-mode
))
199 ;; global key bindings
200 (global-set-key (kbd "C-c m") #'gnus-plugged
)
201 (global-set-key (kbd "C-c M") #'gnus-unplugged
)
203 (with-eval-after-load 'gnus-art
205 gnus-buttonized-mime-types
'("multipart/\\(signed\\|encrypted\\)")
206 gnus-sorted-header-list
'("^From:"
226 "^X-detected-operating-system:"
233 gnus-visible-headers
(mapconcat 'identity
234 gnus-sorted-header-list
236 ;; local-lapsed article dates
237 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
238 gnus-article-date-headers
'(user-defined)
239 gnus-article-time-format
241 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time
))
242 (local (article-make-date-line date
'local
))
243 (combined-lapsed (article-make-date-line date
246 (string-match " (.+" combined-lapsed
)
247 (match-string 0 combined-lapsed
))))
248 (concat local lapsed
))))
249 ;; local key bindings
250 (declare-function org-store-link
"ol" (arg &optional interactive?
))
251 (define-key gnus-article-mode-map
(kbd "M-L") #'org-store-link
))
253 (with-eval-after-load 'gnus-sum
254 (csetq gnus-thread-sort-functions
'(gnus-thread-sort-by-number
255 gnus-thread-sort-by-subject
256 gnus-thread-sort-by-date
))
257 ;; local key bindings
258 (define-key gnus-summary-mode-map
(kbd "M-L") #'org-store-link
)
259 ;; (define-key gnus-summary-mode-map (kbd "r")
260 ;; #'gnus-summary-reply-with-original)
261 ;; (define-key gnus-summary-mode-map (kbd "R")
262 ;; #'gnus-summary-wide-reply-with-original)
263 (defvar b
/gnus-summary-prefix-map
)
264 (define-prefix-command 'b
/gnus-summary-prefix-map
)
265 (define-key gnus-summary-mode-map
(kbd "v")
266 'b
/gnus-summary-prefix-map
)
267 (define-key b
/gnus-summary-prefix-map
(kbd "r")
268 #'gnus-summary-reply
)
269 (define-key b
/gnus-summary-prefix-map
(kbd "w")
270 #'gnus-summary-wide-reply
)
271 (define-key b
/gnus-summary-prefix-map
(kbd "v")
272 #'gnus-summary-show-raw-article
))
274 (add-hook 'gnus-summary-mode-hook
#'b
/no-mouse-autoselect-window
)
277 (with-eval-after-load 'gnus-msg
278 (defvar b
/shemshak-signature
"Amin Bandali
279 https://shemshak.org/~bandali")
280 (defvar b
/uwaterloo-signature
"Amin Bandali, MMath
281 https://shemshak.org/~bandali")
282 (defvar b
/csc-signature
"Amin Bandali (https://shemshak.org/~bandali)
283 Systems Committee <syscom@csclub.uwaterloo.ca>
284 Computer Science Club of the University of Waterloo")
285 (defvar b
/sfl-signature
"Amin Bandali
286 Free Software Consultant
290 gnus-message-replysign t
293 (address "bandali@gnu.org")
294 ("X-Message-SMTP-Method" "smtp fencepost.gnu.org 587"))
295 ;; ("nnimap\\+gnu:l\\..*"
297 ((header "subject" "ThankCRM")
298 (to "webmasters-comment@gnu.org")
300 (eval (setq b
/message-cite-say-hi nil
)))
301 ("nnimap\\+shemshak:.*"
302 (address "amin@shemshak.org")
303 ("X-Message-SMTP-Method" "smtp mail.shemshak.org 587")
305 (signature b
/shemshak-signature
)
306 (gcc "nnimap+shemshak:Sent")
307 (eval (setq b
/message-cite-say-hi t
)))
308 ("nnimap\\+uwaterloo:.*"
309 (address "bandali@uwaterloo.ca")
310 ("X-Message-SMTP-Method" "smtp connect.uwaterloo.ca 587")
312 (signature b
/uwaterloo-signature
))
313 ("nnimap\\+uwaterloo:INBOX"
314 (gcc "\"nnimap+uwaterloo:Sent Items\""))
316 (address "bandali@csclub.uwaterloo.ca")
317 ("X-Message-SMTP-Method" "smtp mail.csclub.uwaterloo.ca 587")
318 (signature b
/csc-signature
)
319 (gcc "nnimap+csc:Sent"))
321 (address "amin.bandali@savoirfairelinux.com")
322 (signature b
/sfl-signature
)
323 ("X-Message-SMTP-Method" "smtp mail.savoirfairelinux.com 587")
324 (gcc "nnimap+sfl:Sent")
325 (eval (setq-local b
/sfl-p t
))))))
327 ;; (with-eval-after-load 'gnus
328 ;; (add-hook 'gnus-message-setup-hook
330 ;; (unless (or (mml-secure-is-encrypted-p)
332 ;; (mml-secure-message-sign)))))
334 (with-eval-after-load 'gnus-topic
336 gnus-topic-line-format
"%i[ %A: %(%{%n%}%) ]%v\n"
338 `(("Gnus" visible nil nil
)
339 (("misc" visible nil nil
))
341 ((string= (system-name) "jirud")
342 '((("sfl" visible nil nil
))))
343 ((string= (system-name) "langa")
344 '((("csc" visible nil nil
))
345 (("uwaterloo" visible nil nil
))
346 (("shemshak" visible nil nil
))
347 (("gnu" visible nil nil
))
348 (("old-gnu" visible nil nil
))))))))
350 (with-eval-after-load 'gnus-agent
351 (csetq gnus-agent-synchronize-flags
'ask
))
353 (with-eval-after-load 'gnus-group
354 (csetq gnus-permanently-visible-groups
"\\(:INBOX$\\|:gnu$\\)"))
356 (with-eval-after-load 'gnus-win
357 (csetq gnus-use-full-window nil
))
359 (with-eval-after-load 'gnus-dired
360 (add-hook 'dired-mode-hook
'gnus-dired-mode
))
362 (with-eval-after-load 'mm-decode
363 (csetq ;; mm-attachment-override-types `("text/x-diff" "text/x-patch"
364 ;; ,@mm-attachment-override-types)
365 mm-discouraged-alternatives
'("text/html" "text/richtext")
366 mm-decrypt-option
'known
367 mm-verify-option
'known
))
369 (with-eval-after-load 'mm-uu
370 (when (version< "27" emacs-version
)
371 (set-face-attribute 'mm-uu-extract nil
:extend t
))
372 (when (version< emacs-version
"27")
373 (csetq mm-uu-diff-groups-regexp
".")))
375 (with-eval-after-load 'mml-sec
376 (csetq mml-secure-openpgp-encrypt-to-self t
377 mml-secure-openpgp-sign-with-sender t
))
379 (provide 'bandali-gnus
)
380 ;;; bandali-gnus.el ends here