-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gnus.el
365 lines (313 loc) · 12.1 KB
/
.gnus.el
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
;;; .gnus.el -- Laptop
;;; Code:
;;; Search engine for imap and gmane (hit `G G' in group buffer)
;;
(require 'nnir)
(require 'cl-lib)
;; Don't read/write to the .newrc file, go straight to the *.eld.
(setq gnus-save-newsrc-file nil
gnus-read-newsrc-file nil)
(setq gnus-read-active-file 'some)
(setq gnus-check-new-newsgroups 'ask-server)
;;; Gnus methods
;;
;;
;; Default method
(setq gnus-select-method '(nntp "news.gmane.org"
(nnir-search-engine gmane)))
;;; To add a mail account:
;;
;; 1) Add an nnimap entry in `gnus-secondary-select-methods'.
;; 2) Add an entry in `gnus-posting-styles'
;; 3) Add an entry in `tv-smtp-accounts'
;; 4) Add an entries in authinfo for imap and smtp refering to labels. (See below)
;; Secondary methods are mails and possibly other nntp servers.
(setq gnus-secondary-select-methods '((nnml "")
;; Add as many gmail account as needed with a label.
;; Add then an entry in .authinfo:
;; machine label port xxx login xxx password xxx
;; (nnimap "gmail" ; Label for reference in .authinfo for machine name.
;; (nnimap-address "imap.gmail.com")
;; (nnimap-fetch-partial-articles "text/"))
;; ;;[1]
;; (nnimap "yahoo"
;; (nnimap-address "imap.mail.yahoo.com")
;; (nnimap-fetch-partial-articles "text/"))
;; [1]
;(nntp "news.gwene.org")
))
;; [1] Don't load mime parts when receiving mail, only text part.
;; Use `A-C' to see entire mail.
;; Nnml mail directory
(setq nnml-directory "~/Mail")
;;; Archivage des mails envoyés
;;
(setq gnus-message-archive-group '((when (message-news-p) "sent-news")))
;;; Smtp settings - Sending mail
;;
;;
;; Posting-styles - must be set correctly for
;; following smtp settings.
;;
;; [EVAL] (info "(gnus) Posting Styles")
;; [EVAL] (info "(gnus) X-Face")
;; [EVAL] (info "(gnus) Face")
(setq gnus-posting-styles
'((".*"
(name "Thierry Volpiatto")
(address "[email protected]")
(organization "Emacs Helm")
(signature-file "~/.signature"))
;; Reply to message sent to gmail with my gmail account.
((header "to" "[email protected]")
(from "Thierry Volpiatto <[email protected]>")
(organization "Emacs Helm")
(signature-file "~/.signature"))
;; Reply to message sent to yahoo with my yahoo account.
((header "to" "[email protected]")
(from "Thierry Volpiatto <[email protected]>")
(signature-file "~/.signature"))
;; Don't use a borring signature for Friends.
(".*Friends"
(from "Thierry Volpiatto <[email protected]>")
(signature-file "~/.signature-friends"))))
;; Don't send to these address in wide reply.
(setq message-dont-reply-to-names '("notifications@github\\.com"
".*@noreply\\.github\\.com"
"thierry\\.volpiatto@gmail\\.com"))
(setq user-mail-address "[email protected]")
(setq user-full-name "Thierry Volpiatto")
;; [smtpmail-async] Experimental, use `smtpmail-send-it' otherwise.
(setq message-send-mail-function 'async-smtpmail-send-it
;smtpmail-debug-info t ; Uncomment to debug
;smtpmail-debug-verb t ; Uncomment to debug on server
mail-specify-envelope-from t ; Use from field to specify sender name.
mail-envelope-from 'header) ; otherwise `user-mail-address' is used.
;; Default settings.
;; This are default setting, they could be modified
;; by `tv-change-smtp-server' according to `tv-smtp-accounts'
;; and `gnus-posting-styles'.
(setq smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-user user-mail-address
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587)
(defvar tv-smtp-accounts
'(("[email protected]"
(:server "smtp.gmail.com"
:port 587
:name "Thierry Volpiatto"))
(:server "smtp.mail.yahoo.com"
:port 587
:name "Thierry Volpiatto"))))
(defun tv-change-smtp-server ()
"Use account found in `tv-smtp-accounts' according to from header.
`from' is set in `gnus-posting-styles' according to `to' header.
or manually with `tv-send-mail-with-account'.
This will run in `message-send-hook'."
(save-excursion
(save-restriction
(message-narrow-to-headers)
(let* ((from (message-fetch-field "from"))
(user-account (cl-loop for account in tv-smtp-accounts thereis
(and (string-match (car account) from)
account)))
(server (cl-getf (cadr user-account) :server))
(port (cl-getf (cadr user-account) :port))
(user (car user-account)))
(setq smtpmail-smtp-user user
smtpmail-default-smtp-server server
smtpmail-smtp-server server
smtpmail-smtp-service port)))))
(add-hook 'message-send-hook 'tv-change-smtp-server)
(defun tv-send-mail-with-account ()
"Change mail account to send this mail."
(interactive)
(save-excursion
(let* ((from (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from")))
(mail (completing-read
"Use account: "
(mapcar 'car tv-smtp-accounts)))
(name (cl-getf (cadr (assoc mail tv-smtp-accounts)) :name))
(new-from (message-make-from name mail)))
(message-goto-from)
(forward-line 0)
(re-search-forward ": " (point-at-eol))
(delete-region (point) (point-at-eol))
(insert new-from))))
(define-key message-mode-map (kbd "C-c p") 'tv-send-mail-with-account)
;;; Junk mail
;;
;;
(when (require 'mm-decode)
(setq mm-discouraged-alternatives
'("text/html"
"text/richtext"
"text/enriched"
"multipart/related"
"image/.*")
mm-automatic-display
(remove "text/html" mm-automatic-display)
gnus-buttonized-mime-types
'("multipart/alternative"
".*/signed"
"multipart/encrypted")))
;;; Remove white space in filenames
;;
;;
(setq mm-file-name-rewrite-functions
'(mm-file-name-delete-control
mm-file-name-delete-gotchas
mm-file-name-trim-whitespace
mm-file-name-collapse-whitespace
mm-file-name-replace-whitespace))
;;; Show all these headers
;;
;;
(setq gnus-visible-headers
'("^From:"
"^Newsgroups:"
"^Subject:"
"^Date:"
"^Followup-To:"
"^Reply-To:"
"^Organization:"
"^Summary:"
"^Keywords:"
"^To:"
"^[BGF]?Cc:"
"^Posted-To:"
"^Mail-Copies-To:"
"^Apparently-To:"
"^X-Gnus-Warning:"
"^Resent-From:"
"^X-Sent:"
"^X-Mailer:"
"^X-Newsreader:"
"^X-User-Agent:"
"^User-Agent:"))
;;; Order of headers
;;
;;
(setq gnus-sorted-header-list '("^From:"
"^Subject:"
"^Summary:"
"^Keywords:"
"^Newsgroups:"
"^Followup-To:"
"^To:"
"^Cc:"
"^Date:"
"^User-Agent:"
"^X-Mailer:"
"^X-Newsreader:"))
;; Ne pas demander si on splitte les pa
(setq message-send-mail-partially-limit nil)
;;; Html renderer
;;
;;
(cond ((fboundp 'w3m)
;; Emacs-w3m
(setq mm-text-html-renderer 'w3m))
((executable-find "w3m")
;; W3m (Don't need emacs-w3m)
(setq mm-text-html-renderer 'w3m-standalone))
(t ; Fall back to shr.
(setq shr-color-visible-luminance-min 75)
(setq shr-width nil) ; Use all window width.
(setq mm-text-html-renderer 'shr)))
;; Try to inline images
(setq mm-inline-text-html-with-images t)
;; Passage à la ligne automatique
;;
(defun tv/message-mode-setup ()
(setq fill-column 72)
(turn-on-auto-fill)
(epa-mail-mode 1))
(add-hook 'message-mode-hook 'tv/message-mode-setup)
;;; Mail encryption.
;;
;;
(setq mml2015-use 'epg)
(setq mml2015-encrypt-to-self t)
;; Verify/Decrypt automatically
;; only if mml knows about the protocol used.
(setq mm-verify-option 'known)
(setq mm-decrypt-option 'known)
(setq gnus-inhibit-mime-unbuttonizing nil)
(setq gnus-buttonized-mime-types '("multipart/signed"
"multipart/alternative"))
;; Automatically sign/encrypt replies to signed/encrypted mails.
(setq gnus-message-replysign t)
(setq gnus-message-replyencrypt t)
;; Suppression de la signature quand on quote.
(setq message-cite-function 'message-cite-original-without-signature)
;; Integration dans dired
(require 'gnus-dired)
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
;; fortune
(add-hook 'gnus-article-mode-hook
#'(lambda ()
(define-key gnus-article-mode-map "i" 'fortune-from-region)))
;; (add-hook 'message-setup-hook 'fortune-to-signature)
;; (message "Making new signature: %s" (fortune-to-signature "~/docs/ascii/misc/fortunes/usenet"))
;; Scoring
;; The scoring system sorts articles and authors you read often to the beginning of the available mails.
;; Less interesting stuff is located at the end.
(setq gnus-use-adaptive-scoring t)
(setq gnus-score-expiry-days 14)
(setq gnus-default-adaptive-score-alist
'((gnus-unread-mark)
(gnus-ticked-mark (from 4))
(gnus-dormant-mark (from 5))
(gnus-saved-mark (from 20) (subject 5))
(gnus-del-mark (from -2) (subject -5))
(gnus-read-mark (from 2) (subject 1))
(gnus-killed-mark (from 0) (subject -3))))
;; Original value
;; '((gnus-kill-file-mark)
;; (gnus-unread-mark)
;; (gnus-read-mark (from 3) (subject 28))
;; (gnus-catchup-mark (subject -8))
;; (gnus-killed-mark (from -2) (subject -18))
;; (gnus-del-mark (from -2) (subject -13)))
(setq gnus-score-decay-constant 1) ;default = 3
(setq gnus-score-decay-scale 0.03) ;default = 0.05
(setq gnus-decay-scores t) ;(gnus-decay-score 1000)
;; Use a global score file to filter gmane spam articles.
(setq gnus-global-score-files
'("~/News/scores/all.SCORE"))
;; all.SCORE contains:
;; (("xref"
;; ("gmane.spam.detected" -1000 nil s)))
(setq gnus-summary-expunge-below -999)
;; Scroll-other-window
(define-key gnus-summary-mode-map (kbd "<C-M-down>") #'(lambda ()
(interactive)
(scroll-other-window 1)))
(define-key gnus-summary-mode-map (kbd "<C-M-up>") #'(lambda ()
(interactive)
(scroll-other-window -1)))
;; Default directory to save attached files
(setq mm-default-directory "~/download/")
;; timestamp
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
(setq gnus-group-line-format "%M\%S\%p\%P\%5y: %(%-40,40g%) %ud\n")
(defun gnus-user-format-function-d (headers)
(declare (special gnus-tmp-group))
(let ((time (gnus-group-timestamp gnus-tmp-group)))
(if time (format-time-string "%b %d %H:%M" time) "")))
(setq gnus-summary-line-format "%U%R%z %(%&user-date; %-15,15f %* %B%s%)\n"
gnus-user-date-format-alist '((t . "%d.%m.%Y %H:%M"))
gnus-sum-thread-tree-false-root ""
gnus-sum-thread-tree-indent " "
gnus-sum-thread-tree-root ""
gnus-sum-thread-tree-leaf-with-other "├► "
gnus-sum-thread-tree-single-leaf "╰► "
gnus-sum-thread-tree-vertical "│")
;; Gravatar
;(setq gnus-treat-from-gravatar 'head) ; in From header
;(setq gnus-treat-mail-gravatar 'head) ; in To/Cc header
;;; .gnus.el ends here