Repository navigation
Expand file tree
/
Copy pathmy-gnus.el
More file actions
423 lines (305 loc) · 14.7 KB
/
Copy pathmy-gnus.el
File metadata and controls
423 lines (305 loc) · 14.7 KB
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
;; from
;; http://www.xsteve.at/prg/gnus/
;; XSteve's Gnus page
;; Gnus is a sophisticated and powerful crossplatform email and news reader.
;; It is implemented in Emacs Lisp. That way you have the full power of Emacs available in your email application.
;; My .gnus explained
;; I subscribed a bunch of mailing lists via news.gmane.org.
;; I use the gmane server as my primary news source.
(setq gnus-select-method '(nntp "news.gmane.org"))
;; Use a smtp server to send emails.
(setq smtpmail-smtp-server "joonhwan.lee@gmail.com")
(setq user-mail-address "joonhwan.lee@gmail.com")
(setq message-send-mail-real-function 'smtpmail-send-it)
;; Display the recipants in gnus summary buffers instead of my mail own mail address for my sent mails.
(setq gnus-ignored-from-addresses "Joonhwan Lee")
;; Set the prefix when using jump to select a newsgroup.
;; needs a newer gnus
;; (setq gnus-group-jump-to-group-prompt '((0 . "nnml:mail.") (1 . "gmane.")
;; (2 . "nnshimbun+")
;; (3 . "nnfolder+archive:")))
(setq gnus-group-jump-to-group-prompt "nnml:mail.")
;; Use nnml as mail backend. Use news.host.com as nntp server.
(setq gnus-secondary-select-methods nil)
;; '((nnml "")
;; (nntp "news.host.com")))
;; Keep a backup of the received mails for 60 days and delete that mails after 60 days without a confirmation.
(setq mail-source-delete-incoming 60)
(setq mail-source-delete-old-incoming-confirm nil)
;; Expireable articles will be deleted after 35 days.
(setq nnmail-expiry-wait 35)
;; Display html emails via emacs-w3m
(setq mm-text-html-renderer 'w3m)
;; Do not use the html part of a message, use the text part if possible!
(setq mm-discouraged-alternatives '("text/html" "text/richtext"))
;; Specify the mail sources from which gnus should fetch new mail. The mail will be transfered to your computer and deleted on the mail host. Below you see an example definition for pop and one for imap. I have some fictional values for the needed entries.
(setq mail-sources
'(;; (pop :server "pop.host.at" :user "xsteve@host.at" :password "pwhost")
(imap :server "imap.gmail.com" :user "joonhwan.lee@gmail.com" ;; :password "??????"
)))
;; ;; Mail splitting is a very powerful and useful feature of gnus. You should add your own rules below. The rules are tried from the first to the last. If a rule matches, the Mail is spooled to the specified mail group. If no rule matches, the mail is delivered to the group "mail.other".
;; (setq nnmail-split-methods 'nnmail-split-fancy)
;; (setq nnmail-split-fancy
;; '(|
;; (: spam-split)
;; (: gnus-registry-split-fancy-with-parent)
;; ;; ("X-BeenThere" "xtla-el-dev@gna.org" "mail.myprg.xtla")
;; ;; (from ".*@amazon.de" "mail.privat.amazon")
;; "mail.other"))
;; Mails and News that you send are stored in the folders "sent-mail" or "sent-news"
(setq gnus-message-archive-group
'((if (message-news-p)
"sent-news"
"sent-mail")))
;; 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))))
;(gnus-killed-mark (from -1) (subject -3))))
;(gnus-kill-file-mark (from -9999)))
;(gnus-expirable-mark (from -1) (subject -1))
;(gnus-ancient-mark (subject -1))
;(gnus-low-score-mark (subject -1))
;(gnus-catchup-mark (subject -1))))
(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. That is a really cool feature.
(setq gnus-global-score-files
'("~/gnus/scores/all.SCORE"))
;; all.SCORE contains:
;;(("xref"
;; ("gmane.spam.detected" -1000 nil s)))
(setq gnus-summary-expunge-below -999)
Summary line format strings
(setq gnus-summary-line-format "%O%U%R%z%d %B%(%[%4L: %-22,22f%]%) %s\n")
(setq gnus-summary-mode-line-format "Gnus: %p [%A / Sc:%4z] %Z")
Threading visual appearance
(setq gnus-summary-same-subject "")
(setq gnus-sum-thread-tree-root "")
(setq gnus-sum-thread-tree-single-indent "")
(setq gnus-sum-thread-tree-leaf-with-other "+-> ")
(setq gnus-sum-thread-tree-vertical "|")
(setq gnus-sum-thread-tree-single-leaf "`-> ")
Use the keybinding M-F7 to toggle between the gnus window configuration and your normal editing windows.
(defun xsteve-gnus ()
(interactive)
(let ((bufname (buffer-name)))
(if (or
(string-equal "*Group*" bufname)
(string-equal "*BBDB*" bufname)
(string-match "\*Summary" bufname)
(string-match "\*Article" bufname))
(progn
(xsteve-bury-gnus))
;unbury
(if (get-buffer "*Group*")
(xsteve-unbury-gnus)
(gnus-unplugged)))))
(defun xsteve-unbury-gnus ()
(interactive)
(when (and (boundp 'gnus-bury-window-configuration) gnus-bury-window-configuration)
(set-window-configuration gnus-bury-window-configuration)))
(defun xsteve-bury-gnus ()
(interactive)
(setq gnus-bury-window-configuration nil)
(let ((buf nil)
(bufname nil))
(dolist (buf (buffer-list))
(setq bufname (buffer-name buf))
(when (or
(string-equal "*Group*" bufname)
(string-equal "*BBDB*" bufname)
(string-match "\*Summary" bufname)
(string-match "\*Article" bufname))
(unless gnus-bury-window-configuration
(setq gnus-bury-window-configuration (current-window-configuration)))
(delete-other-windows)
(if (eq (current-buffer) buf)
(bury-buffer)
(bury-buffer buf))))))
(global-set-key [(meta f7)] 'xsteve-gnus)
Generate the mail headers before you edit your message.
(setq message-generate-headers-first t)
The message buffer will be killed after sending a message.
(setq message-kill-buffer-on-exit t)
When composing a mail, start the auto-fill-mode.
(add-hook 'message-mode-hook 'turn-on-auto-fill)
Increase the score for followups to a sent article.
(add-hook 'message-sent-hook 'gnus-score-followup-article)
(add-hook 'message-sent-hook 'gnus-score-followup-thread)
Toggle the Gcc Header.
The Gcc Header specifies a local mail box that receives a copy of the sent article.
(defun message-toggle-gcc ()
"Insert or remove the \"Gcc\" header."
(interactive)
(save-excursion
(save-restriction
(message-narrow-to-headers)
(if (message-fetch-field "Gcc")
(message-remove-header "Gcc")
(gnus-inews-insert-archive-gcc)))))
(define-key message-mode-map [(control ?c) (control ?f) (control ?g)] 'message-toggle-gcc)
The message-citation-line-function is responsible to display a message citation. The following Code allows to switch
(setq message-citation-line-function 'xsteve-message-citation) ; was message-insert-citation-line
(setq message-cite-function 'message-cite-original-without-signature)
;;
(defun xsteve-message-citation ()
(interactive)
(when message-reply-headers
(xsteve-message-citation-delete)
(message-goto-body)
(let* ((parsed-address (mail-header-parse-address (mail-header-from message-reply-headers)))
(my-bbdb-record (bbdb-search-simple (cdr parsed-address) (car parsed-address)))
(start-pos (point))
(overlay)
(anrede (when my-bbdb-record (bbdb-record-getprop my-bbdb-record 'anrede)))
(full-name
(or (if my-bbdb-record
(bbdb-record-name my-bbdb-record)
(cdr parsed-address))
"Fred Namenlos ")))
(if anrede
(insert (format "%s\n\n" anrede))
(funcall xsteve-message-citation-function full-name))
(unless (eq start-pos (point))
(setq overlay (make-overlay start-pos (point)))
(overlay-put overlay 'xsteve-message-citation nil)))))
(defun xsteve-message-citation-hallo (full-name)
(insert "Hallo " (car (split-string full-name)) "!\n\n"))
(defun xsteve-message-citation-hi (full-name)
(insert "Hi " (car (split-string full-name)) "!\n\n"))
(defun xsteve-message-citation-herr (full-name)
(insert "Hallo Herr " (cadr (split-string (or full-name "Fred Namenlos "))) "!\n\n"))
(defun xsteve-message-citation-default (full-name)
(message-insert-citation-line))
(xsteve-define-alternatives 'xsteve-message-citation-function '(xsteve-message-citation-hallo
xsteve-message-citation-herr
xsteve-message-citation-hi
xsteve-message-citation-default))
(defun xsteve-message-citation-delete ()
(interactive)
(let ((overlay)
(start-pos))
(goto-char (point-min))
(goto-char (next-overlay-change (point)))
(setq overlay (car-safe (overlays-at (point)))) ;; do not use car...
(when overlay
(overlay-get overlay 'xsteve-message-citation)
(setq start-pos (point))
(goto-char (next-overlay-change (point)))
(delete-region start-pos (point)))))
(defun xsteve-message-citation-toggle ()
(interactive)
(save-excursion
(toggle-xsteve-message-citation-function)
(xsteve-message-citation)))
(define-key message-mode-map [f6] 'xsteve-message-citation-toggle)
Bind M-h to a function that shows the latest received mails.
(defun xsteve-show-nnmail-split-history ()
(interactive)
(let ((hi (sort (mapcar 'caar nnmail-split-history) 'string<))
(elem)
(count)
(total))
(while hi
(if (string= elem (car hi))
(setq count (+ count 1))
(setq elem (car hi))
(when total
(setcar total (concat (car total) ": " (number-to-string count))))
(setq count 1)
(add-to-list 'total elem))
(setq hi (cdr hi)))
(if total
(setcar total (concat (car total) ": " (number-to-string count)))
(setq total '("No new Mail")))
(message (format"%s%s" xsteve-check-mail-time (nreverse total)))))
(defun xsteve-get-new-news-set-time ()
(setq xsteve-check-mail-time (format-time-string "[%H:%M] ")))
(unless (boundp 'xsteve-check-mail-time)
(xsteve-get-new-news-set-time))
(add-hook 'gnus-get-new-news-hook 'xsteve-get-new-news-set-time)
(define-key gnus-group-mode-map [(meta h)] 'xsteve-show-nnmail-split-history)
Store gnus specific files to ~/gnus
(setq gnus-directory "~/gnus")
(setq message-directory "~/gnus/mail")
(setq nnml-directory "~/gnus/nnml-mail")
(setq gnus-article-save-directory "~/gnus/saved")
(setq gnus-kill-files-directory "~/gnus/scores")
(setq gnus-cache-directory "~/gnus/cache")
Integration to bbdb and dired
(add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
Use the gnus registry
(require 'gnus-registry)
(gnus-registry-initialize)
Select the header that should be shown. Yes I am interested in the used mail or news client from other people ;-)
(setq gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:\\|^User-Agent:\\|^X-Mailer:\\|^X-Newsreader:")
Specify the order of the header lines
(setq gnus-sorted-header-list '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^Followup-To:" "^To:" "^Cc:" "^Date:" "^User-Agent:" "^X-Mailer:" "^X-Newsreader:"))
Use the topic mode
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
Added some keybindings to the gnus summary mode
(define-key gnus-summary-mode-map [(meta up)] '(lambda() (interactive) (scroll-other-window -1)))
(define-key gnus-summary-mode-map [(meta down)] '(lambda() (interactive) (scroll-other-window 1)))
(define-key gnus-summary-mode-map [(control down)] 'gnus-summary-next-thread)
(define-key gnus-summary-mode-map [(control up)] 'gnus-summary-prev-thread)
I use gnus-alias to make it possible to use different mail addresses for me. I have changed the mail addresses below to some invalid ones. I can use C-c C-p to select an identity from the given list. It is also possible via gnus-alias-identity-rules to select the correct mail address from a given context.
(require 'gnus-alias)
(setq gnus-alias-identity-alist
'(("riic-xsteve" "" "Stefan Reichör " "" nil "" "")
;;("web.de" "" "Stefan Reichör " "" nil "" "Stefan.")
("sigriic" "" "Stefan Reichör " "" nil "" "~/data/.signature-riic")))
(setq gnus-alias-identity-rules '(("xtla.el"
("to" "xtla-el-devNOSPAM@gna.org" current)
"xsteve")))
(setq gnus-alias-default-identity "xsteve")
(gnus-alias-init)
(define-key message-mode-map "\C-c\C-p" 'gnus-alias-select-identity)
My spam settings. I use the spam processing for the gmane groups.
(setq spam-directory "~/gnus/spam/")
(setq gnus-spam-process-newsgroups
'(("^gmane\\."
((spam spam-use-gmane)))))
(require 'spam)
Make it easier to find ham messages in my spam folder nnml:spam.
The following setup highlights some words that I expect in ham messages.
(setq gnus-summary-nospam-highlight-list '("[PATCH]" "svn" "x-dict" "pwsafe"
"emacs" "python"))
(defun gnus-summary-hl-nospam ()
(interactive)
(highlight-regexp (regexp-opt gnus-summary-nospam-highlight-list)))
(defun gnus-summary-hl-nospam-in-spam-group ()
(when (string= gnus-newsgroup-name "nnml:spam")
(message "Highlighting words for possible ham mails")
(gnus-summary-hl-nospam)))
(add-hook 'gnus-summary-prepare-hook 'gnus-summary-hl-nospam-in-spam-group)
Setup the search via gnus-namazu. First create the index via the command line.
# generate the database: look at gnus-directory, mine is "~/gnus"
# ~/gnus/nnml-mail contains the mails
mkdir ~/gnus/namazu
mknmz -a -h -O ~/gnus/namazu ~/gnus/nnml-mail
Enable gnus-namazu. You can start a search vie C-c C-n.
(require 'gnus-namazu)
(gnus-namazu-insinuate)
(setq gnus-namazu-index-update-interval nil)
;; call explicitely M-x gnus-namazu-update-all-indices
Update the namazu index every day at 6:00am
(defun xsteve-gnus-namazu-update-all-indices ()
(interactive)
(gnus-namazu-update-all-indices t))
(defun xsteve-gnus-update-namazu-index ()
(run-at-time "6:00am" nil 'xsteve-gnus-namazu-update-all-indices))
(require 'midnight)
(add-hook 'midnight-hook 'xsteve-gnus-update-namazu-index)
Display the signatures in a less readable font.
(require 'sigbegone)