summaryrefslogtreecommitdiff
path: root/gnus-conf.el
blob: f99301ddb2372546ef94211faa067a89336298d3 (plain)
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
;;; gnus-conf.el --- My Gnus configurations -*- lexical-binding: t; -*-

(require 'gnus)
(require 'epa)
(epa-file-enable)

(setq gnus-select-method '(nnnil ""))
(setq gnus-secondary-select-methods
      '(;; (nntp "news.gmane.io")
        (nnmaildir "private" (directory "~/.nnmaildir"))
        ;; (nnmaildir "sent" (directory "~/.nnmaildir"))
        ;; (nnimap "LocalMail"
        ;;  (nnimap-address "localhost")
        ;;  (nnimap-stream network)
        ;;  (nnimap-server-port 143))
        ))

;;; display using display-buffer

(defun durand-display-gnus (&rest _args)
  "Display the group buffer using display-buffer."
  (cond
   ((null (get-buffer "*Group*"))
    (user-error "No group buffer!"))
   (t
    (quit-window)
    (display-buffer (get-buffer "*Group*")))))

(advice-add #'gnus :after #'durand-display-gnus)

(defun durand-gnus-kill-tab (&rest _args)
  "Kill the tab when exiting Gnus."
  (cond
   ((durand-member "email"
                   (mapcar (lambda (tab) (cdr (assq 'name tab)))
                           (funcall tab-bar-tabs-function))
                   #'string=)
    (tab-bar-close-tab-by-name "email"))))

(defun durand-gnus-quit ()
  "Quit and kill tab at the same time."
  (interactive)
  (bury-buffer)
  (durand-gnus-kill-tab))

(add-hook 'gnus-exit-gnus-hook #'durand-gnus-kill-tab)

;;; repunctuate sentences

(add-hook 'gnus-part-display-hook 'gnus-treat-repunctuate)

;;;###autoload
(defun gnus-treat-repunctuate ()
  "Do a quick repunctuation."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (repunctuate-sentences t)))

;;; To be able to see the encrypted mails sent by me.

(setq mml-secure-openpgp-encrypt-to-self t)

;;; mail aliases

(setq message-mail-alias-type 'abbrev)

;;; Decryptions and signatures

(setq gnus-buttonized-mime-types '("multipart/signed" "multipart/alternative"))

(setq mm-decrypt-option 'known)

(setq mm-verify-option 'known)

;;; Update by mu4e

(declare-function #'mu4e-update-mail-and-index "mu4e" (RUN-IN-BACKGROUND))

(define-key gnus-group-mode-map (vector 117) #'mu4e-update-mail-and-index)
(define-key global-map (vector ?\C-c ?g) 'gnus)

;;; user settings

(setq gnus-ignored-from-addresses "mmemmew@gmail.com")

(setq send-mail-function #'smtpmail-send-it)
(setq smtpmail-smtp-user "mmemmew@gmail.com")

(setq gnus-user-agent '(emacs gnus config))

(setq mail-user-agent 'gnus-user-agent)

(setq read-mail-command 'gnus)

(set 'gnus-novice-user nil)

(setq nnmail-expiry-wait 'immediate)

;;; parameters

(setq gnus-parameters
      `((".*"
         (posting-style
          (gcc "nnmaildir+private:Sent")))))

(require 'gnus-msg)

;;; posting style

(setq gnus-posting-styles
      '((".*"
         (signature "李俊緯")
         (address "mmemmew@gmail.com")
         (From (format "Durand <%s>" user-mail-address)))
        ((header "from" "protesilaos")
         (signature "Durand"))
        ((header "from" "tan\\|mlh\\|hsialc\\|tingyu")
         (name "李俊緯")
         (From (format "李俊緯 <%s>" user-mail-address))
         (body "老師好:\n")
         (signature "生 俊緯"))))

(setq gnus-gcc-mark-as-read t)

;;; Call me an expert.

(setq gnus-expert-user t)

(setq gnus-agent t)

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

;;; treatings

(setq gnus-treat-display-smileys nil)
(setq gnus-treat-emphasize t)
(setq gnus-treat-fill-article nil)
(setq gnus-summary-goto-unread 'never)

(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

;;; group line format

(setq gnus-group-line-format "%M%S%p%P%5y:%B%(%g%)\n")

;; (setq gnus-topic-alist
;;       '(("devel" "gmane.emacs.devel")
;;         ("orgmode" "gmane.emacs.orgmode")
;;         ("bug" "gmane.emacs.bugs")
;;         ("emacs")
;;         ("Gnus" "nndraft:drafts")))

;;; thread sorting

(setq gnus-thread-sort-functions
      '(gnus-thread-sort-by-most-recent-date
        gnus-thread-sort-by-most-recent-number))

(setq gnus-subthread-sort-functions
      'gnus-thread-sort-by-date)

(setq gnus-thread-hide-subtree nil)

;;; activate level

(setq gnus-activate-level 4)

(setq gnus-ignored-from-addresses "mmemmew\\.com")

;;; move between topics

(define-key gnus-group-mode-map [?\M-n] 'gnus-topic-goto-next-topic)
(define-key gnus-group-mode-map [?\M-p] 'gnus-topic-goto-previous-topic)

;;; exiting

(define-key gnus-group-mode-map (vector ?q) #'durand-gnus-quit)
(define-key gnus-group-mode-map (vector ?x) #'gnus-group-exit)

;;; agent key bindings

(require 'gnus-agent)

(define-key gnus-agent-summary-mode-map (vector ?$) #'previous-line)
(define-key gnus-agent-summary-mode-map (vector ?ù) #'next-line)
(define-key gnus-agent-summary-mode-map (vector ?n) #'gnus-summary-next-article)
(define-key gnus-agent-summary-mode-map (vector ?p) #'gnus-summary-prev-article)
(define-key gnus-agent-summary-mode-map (vector ?N) #'gnus-summary-next-unread-article)
(define-key gnus-agent-summary-mode-map (vector ?P) #'gnus-summary-prev-unread-article)
(define-key gnus-agent-summary-mode-map (vector ?o) #'gnus-summary-save-article)
(define-key gnus-agent-summary-mode-map (vector ?y) #'gnus-summary-scroll-down)
(define-key gnus-agent-summary-mode-map (vector ?!) #'gnus-summary-mark-as-processable)
(define-key gnus-agent-summary-mode-map (vector ?\M-n) #'gnus-summary-next-thread)
(define-key gnus-agent-summary-mode-map (vector ?\M-p) #'gnus-summary-prev-thread)
(define-key gnus-agent-summary-mode-map (vector ?\C-\M-n) #'gnus-summary-next-group)
(define-key gnus-agent-summary-mode-map (vector ?\C-\M-p) #'gnus-summary-prev-group)
(define-key gnus-agent-summary-mode-map (vector ?z ?t) #'recenter-to-top)
(define-key gnus-agent-summary-mode-map (vector ?z ?b) #'recenter-to-bottom)
(define-key gnus-agent-summary-mode-map (vector ?z ?z) #'recenter-to-middle)

(define-key gnus-agent-group-mode-map (vector ?n) #'gnus-group-next-group)
(define-key gnus-agent-group-mode-map (vector ?p) #'gnus-group-prev-group)
(define-key gnus-agent-group-mode-map (vector ?N) #'gnus-group-next-unread-group)
(define-key gnus-agent-group-mode-map (vector ?P) #'gnus-group-prev-unread-group)

;;; article

(require 'gnus-art)

(define-key gnus-article-mode-map [?z ?t] 'recenter-to-top)
(define-key gnus-article-mode-map [?z ?b] 'recenter-to-bottom)
(define-key gnus-article-mode-map [?z ?z] 'recenter-to-middle)
(define-key gnus-article-mode-map [?o] 'gnus-mime-inline-part)

(setq gnus-article-sort-functions
      '((not gnus-article-sort-by-number)
        (not gnus-article-sort-by-date)))
(setq gnus-html-frame-width 80)
(setq gnus-inhibit-images nil)
(setq gnus-max-image-proportion 0.7)

;;; Summary

(setq gnus-auto-select-first nil)
(setq gnus-summary-ignore-duplicates t)
(setq gnus-suppress-duplicates t)
(setq gnus-summary-goto-unread 'never)
(setq gnus-summary-to-prefix "To: ")
(setq gnus-summary-line-format "%U%R%z %-16,16&user-date; %*%(%-30,30a  %B%s%)\n")
(setq gnus-summary-mode-line-format "%p")
(setq gnus-summary-make-false-root 'adopt)
(setq gnus-sum-thread-tree-false-root "─┬> ")
(setq gnus-sum-thread-tree-indent " ")
(setq gnus-sum-thread-tree-leaf-with-other "├─> ")
(setq gnus-sum-thread-tree-root "")
(setq gnus-sum-thread-tree-single-leaf "└─> ")
(setq gnus-sum-thread-tree-vertical "│")
(setq gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject)

;;; disable auto-save for newrc file

(defun durand-disable-auto-save-for-newsrc-ad (&rest _args)
  "Disable auto-save for newsrc file."
  (cond
   ((get-buffer ".newsrc-dribble")
    (with-current-buffer ".newsrc-dribble"
      (setq-local buffer-auto-save-file-name nil)))))

(advice-add #'gnus :after #'durand-disable-auto-save-for-newsrc-ad)

;;; Supercite

;; This is suggested by the manual
(autoload 'sc-cite-original "supercite" nil t)

;; This is the only thing we need to enable using Supercite
(add-hook 'mail-citation-hook #'sc-cite-original)

;; I can start the eelectirc reference mode later on, by the function
;; `sc-insert-reference' (bound to "C-c C-p w" by default).
(setq sc-electric-references-p nil)

;; I find this style quite balanced: not too verbose but still
;; informative enough
(setq sc-preferred-header-style 1)

;; I used to use the nested style, but now I think the non-nested
;; style is clearer and cleaner
(setq sc-nested-citation-p nil)

;; Don't query me each time
(setq sc-confirm-always-p nil)