public
Description: My configuration files for various applications
Homepage: http://mina86.com/
Clone URL: git://github.com/mina86/dot-files.git
mina86 (author)
Fri Oct 16 02:33:17 -0700 2009
commit  f20802d27bfc52da3bc4038a3042d3ccb058f875
tree    ee7f0243169d09a22185614288afec6b9cd6c5aa
parent  ba198f5843b077cbeff5ad542b8cccd33dc706d2
dot-files / dot-gnus
100644 500 lines (413 sloc) 16.538 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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*-
;; .gnus.el -- GNUS configuration file
;; Copyright 2006-2009 by Michal Nazarewicz (mina86/AT/mina86.com)
;;
;;{{{ Main configration (name, email, fqdn, ...)
 
(setq
 user-full-name "Michal Nazarewicz"
 user-mail-address (eval-when-compile (concat "mina86" "@" "tlen.pl"))
 message-from-style 'angels
 gnus-local-domain "mina86.com"
 message-user-fqdn "erwin.mina86.com"
 gnus-user-agent (format "Gnus/%f (%s) Emacs/%s (Slckware Linux)"
                         (gnus-continuum-version) gnus-version
                         (if (string-match "^[0-9]*\\.[0-9]*" emacs-version)
                             (match-string 0 emacs-version) emacs-version)))
 
;; Email addresses
(setq gnus-ignored-from-addresses
      (eval-when-compile
        (regexp-opt (mapcar (function (lambda (i) (concat (car i)"@"(cdr i))))
                            '(("mina86" . "tlen.pl")
                              ("mina86" . "mina86.com")
                              ("mina86" . "users.sf.net")
                              ("mina86" . "users.sourceforge.net")
                              ("mnazarew" . "stud.elka.pw.edu.pl")
                              ("mnazarewicz" . "gmail.com")
                              ("M.Nazarewicz" . "stud.elka.pw.edu.pl")))))
      message-alternative-emails gnus-ignored-from-addresses)
 
;; Passwords
(defvar mn-gnus-password-gmail-pop3 nil)
(defvar mn-gnus-password-gmail-smtp nil)
(defvar mn-gnus-password-mion-pop3 nil)
(defvar mn-gnus-password-mion-smtp nil)
 
(when (file-exists-p (concat gnus-home-directory "/.passwords.el"))
  (load (concat gnus-home-directory "/.passwords.el")))
 
;;}}}
;;{{{ Directories
 
(setq
 message-directory (concat gnus-home-directory "/Mail")
 nndraft-directory (concat gnus-home-directory "/drafts")
 nnml-use-compressed-files t
 
 gnus-save-newsrc-file nil
 gnus-read-newsrc-file nil
 gnus-startup-file (concat gnus-home-directory "/newsrc"))
 
;;}}}
;;{{{ Select methods & Mail sources
 
(setq
 gnus-select-method '(nntp "news.neostrada.pl")
 gnus-always-read-dribble-file t
 
 gnus-secondary-select-methods
 '((nnml "")))
; (nntp "news.student.pw.edu.pl")))
 
 
;; Mail sources
 
(eval-after-load "mail-source" '(require 'pop3))
(setq
 mail-source-delete-incoming t
 mail-sources
 `((pop :server "pop.gmail.com"
        :port 995
        :user "mnazarewicz"
        :password ,mn-gnus-password-gmail-pop3
        :connection ssl
        :leave t)
   (pop :server "mion.elka.pw.edu.pl"
        :port 995
        :user "mnazarew"
        :password ,mn-gnus-password-mion-pop3
        :connection ssl)))
 
;;}}}
;;{{{ Spliting & Spam
 
(spam-initialize)
(setq
 spam-use-bogofilter t
 
 gnus-spam-newsgroup-contents
 '((".*spam" gnus-group-spam-classification-spam)
   ("nnml:mail.*" gnus-group-spam-classification-ham)
   ("nnml:list.*" gnus-group-spam-classification-ham))
 
 spam-junk-mailgroups '("nnml:spam" "spam")
 spam-split-group "spam"
 
 gnus-ham-process-destinations '(("*.spam" "nnml:mail.misc"))
 gnus-spam-process-destinations '(("nnml:.*" "nnml:spam"))
 
 gnus-spam-process-newsgroups
 '(("nnml:\\(?:mail\\|list\\)\\." ((spam spam-use-bogofilter)))
   ("nnml:spam" ((ham spam-use-bogofilter)))))
 
;; Spliting
 
(setq
 nnmail-treat-duplicates 'delete
 nnmail-cache-accepted-message-ids t
 
 nnmail-split-methods 'nnmail-split-fancy
 nnmail-split-fancy
 (let ((addr-hdr "to\\|from\\|b?cc"))
   `(| (: nnmail-split-fancy-with-parent)
       ("Content-Type"
        ,(eval-when-compile
           (concat "charset="
                   (regexp-opt '("big5" "iso-2022-jp" "ISO-2022-KR" "euc-kr"
                                 "gb2312" "ks_c_5601-1987" "windows-1251"
                                 "koi8-r")
                               t)))
        junk)
       (: spam-split)
       ("X-Mailing-List"
        "linux-\\([-a-z0-9-]*?\\)\\(?:-request\\)?@vger.kernel.org"
        "list.linux.\\1")
       ("X-Gnus-Mail-Source" "mion\\.elka\\.pw\\.edu\\.pl" "mail.mion")
       (,addr-hdr "rxvt-unicode@lists\\.schmorp\\.de" "list.urxvt")
       (,addr-hdr "k02_a\\(?:-request\\)?@staszic\\.waw\\.pl" "list.k02_a")
       (,addr-hdr "mn86@\\(?:g?o2\\|tlen\\).pl" "mail.mn86")
       "mail.misc")))
 
;;}}}
;;{{{ Group parameters, Posting styles & Sending
 
;;{{{ Spelling
 
;; http://www.emacswiki.org/cgi-bin/wiki/GnusSpelling
(gnus-define-group-parameter
 dictionary
 :function-document
 "Return the dictionary used for the current group (if any)."
 :variable-document
 "Alist of regexps (to match group names) and default dictionary to use when composing a new message."
 :parameter-type '(string :tag "Dictionary")
 :parameter-document "\
     The default dictionary to use in the group.")
 
(defun gnus-setup-dictionary (&optional group)
  "Decide wich dictionary to use for group `group`."
  (interactive)
  (let ((dict (gnus-parameter-dictionary
               (or group (if (boundp 'gnus-newsgroup-name)
                             gnus-newsgroup-name "")))))
    (if dict (set (make-local-variable 'ispell-local-dictionary) dict))))
 
(add-hook 'gnus-message-setup-hook 'gnus-setup-dictionary)
(add-hook 'message-mode-hook (function (lambda () (flyspell-mode 1))))
 
;;}}}
;;{{{ Signatures
 
;; Based on randomsig.el
;; http://www.backmes.de/scripts+programs.html
 
(defvar sig-dir "~/.signatures"
  "Directory where signatures are stored. Signatures have to be
saved each in separat file without \"-- \" at the beginning.")
 
(defvar sig-files nil
  "List of signature file names. It may be either a list of
strings, a string, a function returning a list of strings or
a variable symbol. File names are relative to `sig-dir'.")
 
(defvar sig-file-search-unwanted "\\(/\\|^\\)\\(CV\\|RC\\)S$\\|~$"
  "Regular expression matching unwanted files when scanning with
`sig-files-search'")
 
(defvar sig--prompt-history nil)
 
 
(defun sig--files (files)
  "Returns a list of signature file names basaed."
  (if (listp files)
      (if (eq (car files) 'lambda) (sig--files (funcall files)) files)
    (when (symbolp files)
      (cond
       ((fboundp files) (sig--files (funcall files)))
       (( boundp files) (sig--files (symbol-value files)))))))
 
 
(defun sig-files-search (&optional file)
  "Scan `sig-dir' and its subdirectories for regular files.
If FILE is given, only FILE and its subdirectory will be
searched."
  (unless (file-exists-p sig-dir)
    (error "\"%s\" does not exist" sig-dir))
  (unless (file-directory-p sig-dir)
    (error "\"%s\" is not a directory" sig-dir))
  (unless file
    (setq file ""))
 
  (unless (or (string-match "\\(/\\|^\\)\\(\\.\\|\\.\\.\\)$" file)
              (string-match sig-file-search-unwanted file))
    (let ((path (expand-file-name file sig-dir)))
      (cond
       ((file-directory-p path)
        (mapcar (if (string= file "")
                    (lambda (f) (sig-files-search f))
                  (lambda (f) (sig-files-search (concat file "/" f))))
                (directory-files path)))
       ((file-regular-p path) (list file))))))
 
 
(defun sig (file)
  "Sets signature to one in FILE. When called interactivelly
prompts for signature file name from `sig-files' list. When
called with prefix argument will prompt for any file."
  (interactive
   (list (if current-prefix-arg
             (read-file-name "Signature: " sig-dir nil nil t)
           (let ((files (sig--files sig-files)))
             (if files
                 (let ((file
                        (completing-read "Signature: "
                                         files nil t nil
                                         'sig--prompt-history)))
                   (if (string= file "")
                       (error "You have to specify signature")
                     file))
               (error "No signature files."))))))
  (unless (file-name-absolute-p file)
    (setq file (expand-file-name file sig-dir)))
  (save-excursion
    (if (message-goto-signature)
        (save-restriction
          (narrow-to-region (point) (point-max))
          (insert-file-contents file nil nil nil t))
      (insert "-- \n")
      (insert-file-contents file nil nil nil nil))))
 
 
(setq sig-dir (concat gnus-home-directory "/signatures")
      sig-files (sig-files-search))
(define-key message-mode-map "\C-cs" 'sig)
 
;;}}}
 
(setq
 gnus-parameters
 '(("spam" (total-expire . t)
                       (expiry-wait . immediate))
 
   ("^nnml:mail\\." (gcc-self . t))
 
   ("list\\." (subscribed . t)
                       (total-expire . t)
                       (expire-wait . 14))
   ("list\\.linux\\." (expire-wait . 7))
 
   ("list\\.dno" (to-address . "dno@foch.ircx.net.pl")
                       (to-list . "dno@foch.ircx.net.pl"))
 
   ("^nnml:list\\.\\(?:linux\\|git\\)" (dictionary . "british"))
   ("^nnml:" (dictionary . "polish" ))
   ("\\(?:alt\\.\\)?pl\\..*" (dictionary . "polish" ))
   ("" (dictionary . "british")))
 
 gnus-posting-styles
 '((".*"
    ("X-PGP" "B7C6DF1E")
    ("X-PGP-FP" "9134 06FA 7AD8 D134 9D0C C33F 532C CB00 B7C6 DF1E")
 
    (signature-file (concat sig-dir "/english"))
    (x-url "http://mina86.com/"))
   ("^pl\\.\\|^alt\\.pl\\.\\|pw\\."
    (signature-file (concat sig-dir "/polish")))
   ("^nnml:"
    (signature-file (concat sig-dir "/polish")))
   ("^nnml:list\\.\\(linux\\|git\\)"
    (signature-file (concat sig-dir "/english")))
   ("^nnml:mail\\.mion"
    (address (eval-when-compile
               (concat "M.Nazarewicz" "@" "stud.elka.pw.edu.pl"))))
   ("^nnml:mail\\.mn86"
    (address (eval-when-compile (concat "mn86" "@" "o2.pl"))))
   ("^nnml:list.k02_a"
    (address (eval-when-compile (concat "mina86" "@" "tlen.pl"))))))
 
(setq
 gnus-home-score-file
 (list (list "^nnml:" (concat gnus-home-directory "/Mail/all.SCORE"))
       "all.SCORE")
 
 gnus-gcc-mark-as-read t
 message-subscribed-address-functions '(gnus-find-subscribed-addresses))
 
;;{{{ SMTP
 
;; http://www.pvv.ntnu.no/~terjeros/wiki/GnusGmail
 
(setq message-send-mail-function 'smtpmail-send-it)
 
(defvar mn-smtps
  `(("pw\\.edu\\.pl"
     "mion.elka.pw.edu.pl" 587 "mnazarew" ,mn-gnus-password-mion-smtp)
    (""
     "smtp.gmail.com" 587 "mnazarewicz" ,mn-gnus-password-gmail-smtp))
  "The default SMTPS argument for `mn-change-smtp' function (which see).")
 
(setq message-send-mail-function 'smtpmail-send-it)
 
 
(defun mn-change-smtp (&optional from smtps)
  "Change the SMTP server according to the From address. Returns host
name or nil.
 
SMTPS must be a list of 5-element lists or nil. If it's nil
value of `mn-smpts' will be used. The elements of each list are
as follows: regexp, smtp server host name, smtp server port, user
name, password or nil. If ARG or value of From header if ARG is
nil matches regexp the rest of the elements will be applied to
proper smtpmail-* variables.
 
When called interactivelly with a prefix argument will ask for
the value of From header."
  (interactive
   (list
    (and current-prefix-arg
         (read-string "From: " nil nil
                      (save-excursion (save-restriction
                                        (message-narrow-to-headers)
                                        (message-fetch-field "from")))
                      t))))
 
  (unless from
    (setq from (save-excursion (save-restriction
                                 (message-narrow-to-headers)
                                 (message-fetch-field "from")))))
  (unless smtps (setq smtps mn-smtps))
 
  (let (host port)
    (while smtps
      (if (string-match (caar smtps) from)
          (setq smtps (cdar smtps) host (car smtps) port (cadr smtps)
                smtpmail-starttls-credentials (list (list host port () ()))
                smtpmail-auth-credentials (list smtps)
                smtpmail-smtp-server host
                smtpmail-smtp-service port
                smtps nil)
        (setq smtps (cdr smtps))))
    (when (called-interactively-p)
      (if host
          (message "SMTP server set to %s" host)
        (message "No maching SMTP server found")))
    host))
 
(add-hook 'message-setup-hook 'mn-change-smtp)
 
;;}}}
 
;;}}}
;;{{{ Fix Subject in outgoing messages
 
;; http://www.emacswiki.org/cgi-bin/wiki/JorgenSchaefersGnusConfig
(add-hook 'message-header-setup-hook 'mn-fix-re-subject)
(defun mn-fix-re-subject ()
  (while (re-search-forward "^Subject: \\(\\([Oo][Dd][Pp]\\|[Rr][Ee]\\)\\(\\[[0-9]+\\]\\)?: \\)+" nil t)
    (replace-match "Subject: Re: ")))
 
;;}}}
;;{{{ Visualiasation
 
(setq
 gnus-treat-emphasize t
 gnus-treat-buttonize t
 gnus-treat-buttonize-head 'head
 gnus-treat-unsplit-urls 'last
 gnus-treat-leading-whitespace t
 gnus-treat-highlight-citation t
 gnus-treat-highlight-signature t
 gnus-treat-date-lapsed 'head
 gnus-treat-strip-trailing-blank-lines t
 gnus-treat-strip-cr t
 gnus-treat-overstrike t
 gnus-treat-display-x-face t
 gnus-treat-display-face t
 gnus-treat-display-smileys nil
 gnus-treat-x-pgp-sig 'head)
 
(require 'mm-decode)
(setq mm-attachment-override-types '("image/.*"))
(setq mm-discouraged-alternatives '("text/html" "text/richtext")
      gnus-buttonized-mime-types '("multipart/signed" "multipart/encrypted"
                                   "multipart/alternative"))
 
(setq gnus-ignored-mime-types '("text/x-vcard"))
 
(setq gnus-visible-headers
      (eval-when-compile
        (concat "^"
        (regexp-opt
         (list "From" "Newsgroups" "Subject" "Date" "Followup-To" "Reply-To"
               "Organization" "Summary" "Keywords" "To" "Cc" "Bcc" "Gcc" "Fcc"
               "Posted-To" "Mail-Copies-To" "Mail-Followup-To" "Apparently-To"
               "Gnus-Warning" "Resent-From" "X-Sent" "User-Agent" "X-Mailer"
               "Newsreader" "X-Newsreader")
         t) ":")))
 
;;}}}
;;{{{ Format lines
 
(setq
 gnus-group-line-format "%M%S%p%P%5y:%B%(%g%)%l %O\n"
 gnus-topic-line-format "%i%(%{%n%}%) %v\n"
 gnus-summary-line-format "%U%R%z%I%(%[%-16,16f%]: %s%)\n")
 
;;}}}
;;{{{ Bindings
 
(add-hook
 'gnus-group-mode-hook
 (function
  (lambda ()
    (define-key gnus-group-mode-map "\C-cf" 'gnus-topic-select-group))))
 
(add-hook
 'gnus-summary-mode-hook
 (function
  (lambda ()
    (define-key gnus-summary-mode-map "s" 'gnus-summary-mark-as-spam)
    (define-key gnus-summary-mode-map "\C-cf"
      (function
       (lambda () (interactive)
         (or (gnus-summary-show-thread) (gnus-summary-hide-thread)))))
    (define-key gnus-summary-mode-map "\C-c\C-f"
      'gnus-summary-show-all-headers)
    (define-key gnus-summary-mode-map "c"
      (function
       (lambda () (interactive) (gnus-summary-catchup-and-exit nil t))))
    (define-key gnus-summary-mode-map "N"
      (function
       (lambda () (interactive)
         (gnus-summary-catchup nil t) (gnus-summary-next-group t)))))))
 
;;}}}
;;{{{ Misc
 
(setq
 gnus-large-newsgroup 500
 gnus-thread-hide-subtree t
 gnus-summary-gather-subject-limit 'fuzzy
 gnus-interactive-exit nil
 gnus-auto-select-first nil
 gnus-thread-sort-functions '(gnus-thread-sort-by-number
                              gnus-thread-sort-by-total-score))
 
(gnus-compile)
;(setq gnus-topic-display-empty-topics nil)
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
 
;; Daemon
;(gnus-demon-add-handler 'gnus-demon-scan-mail 15 15)
(gnus-demon-add-handler 'gnus-group-get-new-news 15 15)
(gnus-demon-init)
 
;;}}}
;;{{{ PGG
 
(autoload 'pgg-encrypt-region "pgg"
  "Encrypt the current region." t)
(autoload 'pgg-encrypt-symmetric-region "pgg"
  "Encrypt the current region with symmetric algorithm." t)
(autoload 'pgg-decrypt-region "pgg"
  "Decrypt the current region." t)
(autoload 'pgg-sign-region "pgg"
  "Sign the current region." t)
(autoload 'pgg-verify-region "pgg"
  "Verify the current region." t)
(autoload 'pgg-insert-key "pgg"
  "Insert the ASCII armored public key." t)
(autoload 'pgg-snarf-keys-region "pgg"
  "Import public keys in the current region." t)
 
(setq pgg-scheme 'gpg
      pgg-gpg-user-id "mina86"
      pgg-gpg-program "gpg2"
; pgg-gpg-use-agent nil
; pgg-cache-passphrase nil
      gnus-treat-x-pgp-sig t
      mm-verify-option 'known
      mm-decrypt-option 'known)
 
(add-hook 'gnus-message-setup-hook
          (function (lambda ()
                      (if (string-match ":\\(mail\\|list\\)\\."
                                        gnus-newsgroup-name)
                          (mml-secure-message-sign-pgpmime)))))
 
;;}}}