aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/init/ycp-gnus.el
blob: 407d89bb766c24c5c53b90de6ec56730af36c2df (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
;;; ycp-gnus.el -- My config for email etc -*- lexical-binding: t -*-

;; Copyright (C) 2023 Free Software Foundation.

;; Author: Yuchen Pei <id@ypei.org>
;;         Protesilaos Stavrou <info@protesilaos.com>
;; Maintainer: 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 mail-user-agent 'message-user-agent)
(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

;;;; `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 t
        message-citation-line-format
	      "On %a %Y-%m-%d %H:%M:%S %z, %N wrote:\n")
  (add-hook 'message-setup-hook #'message-sort-headers)
  )

(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)
  (dolist (mode '(gnus-group-mode-hook
                  gnus-summary-mode-hook
                  gnus-browse-mode-hook))
    (add-hook mode #'hl-line-mode))
  (require 'my-gnus)
  (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)
  )

(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)
  )

;; 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
    "M-u" nil
    "M-&" nil
    "m" #'my-gnus-move-article-like-mu4e
    "r" #'my-gnus-archive-article-like-mu4e
    "d" #'my-gnus-trash-article-like-mu4e
    "." #'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 ".*")) ; all images in headers are outright
                                        ; annoying---disabled!
;; gnus-desktop-notify
(my-package gnus-desktop-notify
  (:delay 30)
  (gnus-desktop-notify-mode)
  (setq gnus-desktop-notify-groups 'gnus-desktop-notify-explicit)
  )

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

;;; bbdb
(my-package bbdb
  (:delay 60)
  (bbdb-initialize)
  (setq bbdb-mail-user-agent 'gnus-user-agent)
  (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))

(provide 'ycp-gnus)