aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/init/ycp-gnus.el
blob: 305225f92aba8f18047ab73259ec580ed7947e14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
;;; ycp-gnus.el -- My config for email etc -*- lexical-binding: t -*-

;; Copyright (C) 2023 Free Software Foundation.

;; Author: Yuchen Pei <id@ypei.org>
;; Package-Requires: ((emacs "28.2"))

;; This file is part of dotfiles.

;; dotfiles is free software: you can redistribute it and/or modify it under
;; the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; dotfiles is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
;; Public License for more details.

;; You should have received a copy of the GNU Affero General Public
;; License along with dotfiles.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; My config for email etc. Covers gnus, bbdb, message mode etc.

;;; Code:


(my-setq-from-local user-mail-address user-full-name)
(setq auth-sources '("~/.authinfo.gpg"))

;;; `mm-encode'
(my-package mm-encode
  (setq mm-encrypt-option nil   ; use 'guided if you need more control
        mm-sign-option nil))  ; same

(my-package mm-decode
  (setq mm-discouraged-alternatives '("text/html" "text/richtext")))

;;; `mml-sec'
(my-package mml-sec
  (setq mml-secure-openpgp-encrypt-to-self t
        mml-secure-openpgp-sign-with-sender t
        mml-secure-smime-encrypt-to-self t
        mml-secure-smime-sign-with-sender t))

;;; `message'
(my-package message
  (setq mail-user-agent 'message-user-agent
        message-elide-ellipsis "\n> [... %l lines elided]\n"
        compose-mail-user-agent-warnings nil
        message-mail-user-agent t         ; use `mail-user-agent'
        message-citation-line-function #'message-insert-formatted-citation-line
        message-ignored-cited-headers ""  ; default is "." for all headers
        message-confirm-send nil
        message-kill-buffer-on-exit t
        message-wide-reply-confirm-recipients nil
        message-citation-line-format
	      "On %a %Y-%m-%d %H:%M:%S %z, %N wrote:\n")
  (add-hook 'message-setup-hook #'message-sort-headers)
  (require 'my-gnus)
  (my-keybind message-mode-map
    "M-n" #'my-message-after-next-cited
    "M-p" #'my-message-before-previous-cited
    "C-c M-e" #'my-message-elide-remaining)
  )

(my-package smtpmail
  (my-setq-from-local smtpmail-default-smtp-server
                      smtpmail-smtp-server smtpmail-stream-type)
  (setq smtpmail-smtp-service 587
        smtpmail-queue-mail nil))

;;; `sendmail' (mail transfer agent)
(setq send-mail-function 'smtpmail-send-it)

;;; gnus
(my-package gnus
  (setq gnus-select-method '(nnnil ""))
  (setq gnus-group-line-format "%M%S%p%P%5y:%B%(%G%)
")
  (my-setq-from-local gnus-secondary-select-methods)
  (setq gnus-agent t)
  (setq mail-user-agent 'gnus-user-agent)
  (dolist (mode '(gnus-group-mode-hook
                  gnus-summary-mode-hook
                  gnus-browse-mode-hook))
    (add-hook mode #'hl-line-mode))
  (require 'my-gnus)
  (require 'my-buffer)
  (my-setq-from-local my-gnus-inbox-group
                      my-gnus-group-alist)
  (my-keybind global-map
    "C-c n i" #'my-gnus-open-inbox
    "C-c n n" #'my-gnus-start
    "C-c n u" #'gnus-group-get-new-news)
  (my-server-timer my-gnus-new-news-timer nil 300
                   'my-gnus-group-get-new-news-quietly)
  ;; https://superuser.com/questions/519685/gnus-get-rid-of-mail-and-news-folders
  ;; this also fixes issues with presumably nonexisting
  ;; nndraft-directory causing
  ;; (wrong-type-argument stringp nndraft-directory)
  ;; which may require a restart of gnus to fix
  (setq message-directory "~/.emacs.d/mail/")
  (setq gnus-directory "~/.emacs.d/news/")
  (setq nnfolder-directory "~/.emacs.d/mail/archive")
  (setq nndraft-directory "~/.emacs.d/mail/drafts/")
  )

(my-configure
  (:delay 10)
  (org-link-set-parameters "gnus" :follow #'my-org-open-gnus-link))

(my-package gnus-dired
  (add-hook 'dired-mode-hook #'turn-on-gnus-dired-mode))

(my-package gnus-msg
  (setq gnus-gcc-mark-as-read t)
  (setq gnus-message-replysign t)
  (my-setq-from-local gnus-posting-styles)
  (my-override mm-display-external)
  (add-hook 'gnus-message-setup-hook #'message-remove-blank-cited-lines)
  (add-hook 'gnus-message-setup-hook #'my-message-remove-trailing-cited-lines)
  )

;; checking sources
(my-package gnus-start
  (setq gnus-check-new-newsgroups 'ask-server)
  (setq gnus-read-active-file 'some)
  (setq gnus-use-dribble-file t)
  (setq gnus-always-read-dribble-file t))

(my-package gnus-search
  (setq gnus-search-use-parsed-queries t))

(my-package gnus-win
  (setq gnus-use-full-window nil))

(my-package gnus-topic
  (require 'my-gnus)
  (my-keybind gnus-topic-mode-map
    "u" #'my-gnus-topic-up
    "<RET>" #'my-gnus-topic-select-group)
  )

(my-package gnus-group
  (require 'my-gnus)
  (my-keybind gnus-group-mode-map
    "n" #'next-line
    "p" #'previous-line
    "m" #'my-gnus-group-compose
    "M-&" nil
    "<RET>" #'my-gnus-topic-select-group)
  (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
  )

(my-package gnus-sum
  (require 'my-gnus)
  (setq gnus-ignored-from-addresses user-full-name)
  (my-keybind gnus-summary-mode-map
    "n" #'my-gnus-summary-next-article-like-mu4e
    "p" #'my-gnus-summary-prev-article-like-mu4e
    "q" #'my-gnus-summary-exit-like-mu4e
    "g" #'gnus-group-get-new-news-this-group
    "M-u" nil
    "M-&" nil
    "M" #'my-gnus-move-article-like-mu4e
    "a" #'my-gnus-archive-article-like-mu4e
    "c" #'org-capture
    "t" #'my-org-capture-todo
    "m" #'gnus-summary-post-news
    "k" #'my-gnus-trash-article-like-mu4e
    "r" #'gnus-article-reply-with-original
    "R" #'gnus-article-wide-reply-with-original
    "." #'gnus-summary-show-raw-article)
  (setq gnus-sum-thread-tree-root ""
        gnus-sum-thread-tree-single-leaf "└>"
        gnus-sum-thread-tree-leaf-with-other "├>"
        gnus-sum-thread-tree-indent " ")
  (setq gnus-summary-line-format "%*%U%R%z %d %(%-20,20f%) %B%S
")
  (setq gnus-thread-sort-functions
        '(gnus-thread-sort-by-most-recent-date))
  )

(my-package nnrss
  (:delay 60)
  (setq nnrss-use-local t))

(my-package gnus-art
  (setq gnus-inhibit-images t)
  (setq gnus-treat-display-smileys nil)
  (setq gnus-article-x-face-too-ugly ".*")
  ;; shows a radio button in a multipart article to choose which part
  ;; to display
  (setq gnus-buttonized-mime-types '("multipart/alternative"))
  (setq gnus-visible-headers
        "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^In-Reply-To"))
;;; gnus-desktop-notify
(my-package gnus-desktop-notify
  (:delay 30)
  (gnus-desktop-notify-mode)
  (setq gnus-desktop-notify-groups 'gnus-desktop-notify-explicit)
  (setq gnus-desktop-notify-uncollapsed-levels 2)
  )

(my-package gnus-demon
  (gnus-demon-add-scanmail))

;;; bbdb
(my-package bbdb
  (:delay 5)
  (bbdb-initialize 'gnus 'message)
  (bbdb-mua-auto-update-init 'gnus 'message)
  (setq bbdb-dedicated-window t)
  (setq bbdb-message-all-addresses t)
  (setq bbdb-mua-pop-up-window-size .15)
  (setq bbdb-new-mails-primary nil)
  (setq bbdb-ignore-redundant-mails t)
  (setq bbdb-mail-user-agent 'gnus-user-agent)
  (setq bbdb-update-records-p 'create)
  (setq bbdb-message-clean-mail-function 'my-bbdb-clean-mail)
  (my-setq-from-local bbdb-message-ignore-mail-re)
  (setq bbdb-add-name nil)
  (require 'my-bbdb)
  (my-keybind bbdb-mode-map "C-c C-c" #'my-bbdb-done)
  (setq bbdb-phone-style nil
        bbdb-default-country nil)
  (my-override bbdb-read-record)
  (my-override bbdb-create)
  (my-keybind global-map
    "C-c b a" #'my-bbdb-all
    "C-c b b" #'bbdb
    "C-c b c" #'bbdb-create)
  )

(my-package bbdb-anniv (:delay 60))

;; bbdb-vcard
(my-package bbdb-vcard
  (:delay 60)
  (bbdb-vcard-default-keybindings)
  (my-setq-from-local bbdb-vcard-default-dir))

(my-package my-url-rewrite
  (:delay 60))

(my-package traclicker
  (:delay 60)
  (my-setq-from-local tracli-senders tracli-maildirs)
  (my-server-timer my-tracli-timer nil 3600 #'tracli-scan)
  (setq tracli-url-rewriter 'my-url-strip-drw-tracking-params))

(provide 'ycp-gnus)