conf

view .gnus @ 375:26aed4e65671

cleanup hgrc a bit
author Alexander Solovyov <alexander@solovyov.net>
date Mon Jan 23 18:20:04 2012 +0200
parents f304ab9d4c4a
children
line source
1 ;; -*- mode: Emacs-Lisp -*-
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Gnus config
4 ;; (c) Alexander Solovyov 2004-2008
5 ;; piranha AT piranha.org.ua
6 ;;
7 ;; Thanks to all, who has helped me in creation, especially to:
8 ;; Yuriy Sazonets
9 ;; Alexander Zayats
10 ;; Emacswiki.org
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 ;;;;;;;;;;;
14 ;; graphics
15 ;;;;;;;;;;;
17 ;; defined also in .emacs, but to be sure...
18 (defconst graf
19 (not (eq window-system 'nil))
20 "Are we running window system?")
22 ;;;;;;;;;;
23 ;; Loading
24 ;;;;;;;;;;
25 (when (file-exists-p "~/.secrets.el")
26 (load "~/.secrets.el"))
28 ;;;;;;;;;;;
29 ;; Language
30 ;;;;;;;;;;;
32 (setq mm-body-charset-encoding-alist '((koi8-u . 8bit)))
33 (setq gnus-group-posting-charset-alist nil)
34 (setq gnus-group-charset-alist nil)
35 (push '(".*" koi8-u t) gnus-group-posting-charset-alist)
36 (push '(".*" koi8-u t) gnus-group-charset-alist)
38 ;;;;;;;;;;
39 ;; General
40 ;;;;;;;;;;
42 ;; auto word-wrap
43 (add-hook 'message-mode-hook
44 (lambda ()
45 (setq fill-column 72)
46 (turn-on-auto-fill)))
48 (add-hook 'message-mode-hook 'turn-on-orgstruct++)
50 ;; remove thouse ugly red line endings
51 (defun disable-trailing-whitespace ()
52 (setq show-trailing-whitespace nil))
53 (add-hook 'gnus-summary-mode-hook 'disable-trailing-whitespace)
54 (add-hook 'gnus-group-mode-hook 'disable-trailing-whitespace)
55 (add-hook 'gnus-article-mode-hook 'disable-trailing-whitespace)
57 (setq
58 ;; be verbose
59 gnus-novice-user nil
60 ;; where move expired messages
61 nnmail-expiry-target "nnml:expired"
62 ;; don't read whole active file (see help for add info)
63 gnus-read-active-file nil
64 ;; ask server for new newsgroups
65 gnus-check-new-newsgroups nil
66 ;; smileys suck
67 gnus-treat-display-smileys nil
68 ;; all cites must be highlighted
69 gnus-cite-minimum-match-count 1
70 ;; gnus directory :))
71 gnus-directory "~"
72 ;; how many messages must has group, for asking when entering
73 gnus-large-newsgroup 300
74 ;; split long outgoing mail
75 ; message-send-mail-partially-limit 380000
76 ;; highlight only good signatures
77 gnus-signature-separator "^-- |______+$"
78 ;; don't insert Cancel-Lock
79 message-insert-canlock nil
80 )
82 ;; User settings
83 (setq
84 user-name "piranha"
85 user-full-name "Alexander Solovyov"
86 user-mail-address "piranha@piranha.org.ua"
87 message-alternative-emails
88 (regexp-opt '("asolovyov@rainboo.com" "alexander.solovyov@gmail.com" "alexander.solovyov@willowcode.com"))
89 )
91 ;; Send mail via sendmail
92 (setq message-send-mail-function 'message-send-mail-with-sendmail)
94 ;; Send mail via SMTP
95 ;(setq
96 ; gnus-local-domain "piranha.org.ua"
97 ; smtpmail-default-smtp-server "viii.ntu-kpi.kiev.ua"
98 ; smtpmail-local-domain "viii.ntu-kpi.kiev.ua"
99 ; smtpmail-default-smtp-server "localhost"
100 ; message-send-mail-function 'smtpmail-send-it
101 ; smtpmail-auth-login-username "piranha"
102 ;)
104 ;(setq smtpmail-debug-info t)
106 ;; gnus-parameters
107 (setq gnus-parameters
108 '((".*"
109 (gnus-show-threads t)
110 (gnus-use-scoring nil)
111 ; (display . all)
112 )))
114 ;; Show text before html
115 (eval-after-load "mm-decode"
116 '(progn
117 (add-to-list 'mm-discouraged-alternatives "text/html")
118 (add-to-list 'mm-discouraged-alternatives "text/richtext")))
120 ;;;;;;;
121 ;; News
122 ;;;;;;;
124 (setq gnus-select-method '(nntp "news.ntu-kpi.kiev.ua"))
125 (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
127 ;(setq gnus-select-method '(nnnil ""))
129 ;; headers displayed
130 (setq gnus-visible-headers
131 '("From:"
132 "^Newsgroups:"
133 "^Reply-To:"
134 "^Subject:"
135 ; "^Message-ID:"
136 "^Date:"
137 "^To:"
138 "^Cc:"
139 "^Posted-To:"
140 "^Mail-Copies-To:"
141 "^Resent-From:"
142 "^X-Sent:"
143 ; "^User-Agent:"
144 ; "^Content-Type:"
145 "^X-Newsreader:"
146 "^NNTP-Posting-Host:"
147 "^Followup-To:"
148 ))
150 ;; message forwarding
151 (setq
152 message-forward-as-mime nil
153 message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-\\|^References\\|^Xref\\|^In-Reply-To\\|^Received\\|^NNTP\\|^Return-Path\\|^Sender\\|^Approved\\|^User-Agent\\|^List-\\|^Error-To\\|^FL-\\|^Precedence\\|^Gnus-\\|^Path\\|^Cancel-Lock\\|^Face")
156 ;;;;;;;
157 ;; Mail
158 ;;;;;;;
160 (setq mail-sources nil)
161 (setq gnus-secondary-select-methods
162 '((nnimap "mail"
163 (nnimap-address "localhost")
164 (nnimap-stream network))))
166 ;(setq imap-ssl-program "openssl s_client -tls1 -connect %s:%p")
167 ;; (setq gnus-secondary-select-methods
168 ;; '((nnimap "imap.gmail.com"
169 ;; (nnimap-address "imap.gmail.com")
170 ;; (nnimap-authinfo-file "~/.imap-authinfo")
171 ;; (nnimap-server-port 993)
172 ;; (nnimap-stream ssl)
173 ;; ; (nnimap-list-pattern ("INBOX" ".*"))
174 ;; )))
176 (defun prh:mail-date (u) (concat u (format-time-string ".%Y.%m" (current-time))))
177 (defun prh:mail-date2 (u) (concat u (format-time-string ".%Y" (current-time))))
179 ;(setq nnmail-split-methods 'nnmail-split-fancy)
180 ;(setq nnmail-split-fancy
181 ; '(|
182 ; ("\\(To\\|Cc\\)" ".*hostels.*@ntu-kpi\\.kiev\\.ua.*" "hostels")
183 ; ("\\(To\\|Cc\\)" ".*all-admins@ntu-kpi\\.kiev\\.ua.*" "hostels")
184 ; ("\\(To\\|Cc\\)" ".*humor@xcp\\.kiev\\.ua.*" (: prh:mail-date2 "humor"))
185 ; ("From" ".*daily@security\\.nnov\\.ru.*" "security")
186 ; ("\\(To\\|Cc\\)" ".*anime_kpi@yahoogroups.com.*" "anime_kpi")
187 ; ("From" ".*Alexander Solovyov \\[Moderator\\].*" "moder")
188 ; ("From" ".*Nikita Gubenko \\[CoModerator\\].*" "moder")
189 ; ("List-Id" ".*c-p-c.googlegroups.com.*" "cpc")
190 ; ("List-Id" ".*newstalk.news.ntu-kpi.kiev.ua.*" "news-talk")
191 ; ("List-Id" ".*exim-users.exim.org.ua.*" "exim")
192 ; ("List-Id" ".*eth0.googlegroups.com.*" "eth0")
193 ; ("List-Id" ".*users.lists.eth0.net.ua.*" "eth0-public")
194 ; ("List-Id" ".*sudoers.lists.eth0.net.ua.*" "eth0-sudoers")
195 ; ("List-Id" ".*ik22.lists.eth0.net.ua.*" "ik22")
196 ; ("From" ".*@livejournal.com.*" "lj")
197 ; ("From" ".*root@eth0.net.ua.*" "root")
198 ; ("Subject" ".*\\*\\*\\*SPAM\\*\\*\\*.*" "spam")
199 ; (any ".*" (: prh:mail-date "inbox"))
200 ; ))
203 ;; save messages
204 ;(setq gnus-message-archive-group '(
205 ; (if (message-news-p) (concat "nnimap+piranha.org.ua:sent-news" (format-time-string ".%Y.%m" (current-time)))
206 ; (concat "nnimap+piranha.org.ua:sent" (format-time-string ".%Y.%m" (current-time))))))
207 (defun prh:archive-mailbox-date (mailbox)
208 (concat mailbox (format-time-string ".%Y.%m" (current-time))))
209 (setq gnus-message-archive-group '(
210 (if (message-news-p) (prh:archive-mailbox-date "nnimap+mail:sent-news")
211 (prh:archive-mailbox-date "nnimap+mail:sent-mail"))))
213 ;;;;;;;;;;;;
214 ;; Threading
215 ;;;;;;;;;;;;
217 ; If `some', only fill in the gaps that are needed to tie loose threads
218 ; together. If `more', fill in all leaf nodes that Gnus can find. If
219 ; non-nil and non-`some', fill in all gaps that Gnus manages to guess.
220 (setq gnus-build-sparse-threads 'more)
222 ;; build threads by references, not subj
223 (setq gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references)
225 ;; summary buffer formatting
226 (setq gnus-thread-sort-functions
227 '(gnus-thread-sort-by-date))
228 ; gnus-thread-sort-by-number
229 ; gnus-thread-sort-by-subject
230 ; gnus-thread-sort-by-author
231 ; gnus-thread-sort-by-score
232 ; gnus-thread-sort-by-total-score))
234 ;; yet another threading
235 (setq gnus-summary-line-format
236 ":%U%R| %B %s %-80=|%4L |%-20,20f |%&user-date; \n")
237 ;(setq gnus-summary-line-format (concat
238 ; "%*%5{%U%R%z%}"
239 ; "%4{\x49022%}"
240 ; "%2{%-10&user-date;%}"
241 ; "%4{\x49022%}"
242 ; "%4{\x49022%}"
243 ; "%2{ %}%(%-24,24n"
244 ; "%4{\x49022%}"
245 ; "%2{%5i%}"
246 ; "%4{\x49022%}"
247 ; "%2{%6k %}%)"
248 ; "%4{\x49022%}"
249 ; "%2{ %}%3{%B%}%1{%s%}\n"))
251 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
252 ;; the best! unicode threading pointers
253 ;(when graf
254 ; (setq gnus-sum-thread-tree-root "\x4912f ")
255 ; (setq gnus-sum-thread-tree-single-indent "\x4912e ")
256 ; (setq gnus-sum-thread-tree-leaf-with-other "\x4903c\x49020\x490fa ")
257 ; (setq gnus-sum-thread-tree-vertical "\x49022")
258 ; (setq gnus-sum-thread-tree-single-leaf "\x490b0\x49020\x490fa "))
259 ;; here unicode threading ends
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262 ;(when graf
263 ; (setq gnus-group-highlight
264 ; '(((> unread 200) . my-group-face-1)
265 ; ((and (< level 3) (zerop unread)) . my-group-face-2)
266 ; ((< level 3) . my-group-face-3)
267 ; ((zerop unread) . my-group-face-4)
268 ; (t . my-group-face-5))))
270 ;; always show MIME buttons
271 (setq gnus-inhibit-mime-unbuttonizing t)
274 ;;;;;;
275 ;; PGG
276 ;;;;;;
278 (require 'pgg)
279 (autoload 'pgg-encrypt-region "pgg"
280 "Encrypt the current region." t)
281 (autoload 'pgg-decrypt-region "pgg"
282 "Decrypt the current region." t)
283 (autoload 'pgg-sign-region "pgg"
284 "Sign the current region." t)
285 (autoload 'pgg-verify-region "pgg"
286 "Verify the current region." t)
287 (autoload 'pgg-insert-key "pgg"
288 "Insert the ASCII armored public key." t)
289 (autoload 'pgg-snarf-keys-region "pgg"
290 "Import public keys in the current region." t)
292 ;; verify/decrypt only if mml knows about the protocl used
293 (setq mm-verify-option 'known)
294 (setq mm-decrypt-option 'known)
296 ;;Here we make button for the multipart
297 (setq gnus-buttonized-mime-types '("multipart/encrypted" "multipart/signed"))
299 ;; Automcatically sign when sending mails
300 ;(add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
302 ;; Enough explicit settings
303 (setq pgg-passphrase-cache-expiry 300)
304 ;(setq pgg-default-user-id prh::primary-key)
306 ;; regexp of groups from which new messages are mime signed by default
307 ;(setq my-sign-mime-group-regexp "^\\(INBOX.\\|\\)mail.work")
309 ;; hook to setup message
310 ;(defun my-mml-secure-message-sign-mime ()
311 ; (when (string-match
312 ; my-sign-mime-group-regexp
313 ; gnus-newsgroup-name)
314 ; (mml-secure-message-sign-smime)))
316 ;; plug this into message-setup-hook
317 ;(add-hook 'message-setup-hook 'my-mml-secure-message-sign-mime)
319 ;; Automatic decryption/verification of gpg/pgp parts
321 ;; Tells Gnus to inline the part
322 (eval-after-load "mm-decode"
323 '(add-to-list 'mm-inlined-types "application/pgp$"))
324 ;; Tells Gnus how to display the part when it is requested
325 (eval-after-load "mm-decode"
326 '(add-to-list 'mm-inline-media-tests '("application/pgp$"
327 mm-inline-text identity)))
328 ;; Tell Gnus not to wait for a request, just display the thing
329 ;; straight away.
330 (eval-after-load "mm-decode"
331 '(add-to-list 'mm-automatic-display "application/pgp$"))
332 ;; But don't display the signatures, please.
333 (eval-after-load "mm-decode"
334 (quote (setq mm-automatic-display (remove "application/pgp-signature"
335 mm-automatic-display))))
337 ;;;;;;;
338 ;; BBDB
339 ;;;;;;;
341 (when (file-directory-p "~/var/bbdb/lisp")
342 (add-to-list 'load-path "~/var/bbdb/lisp"))
344 (autoload 'bbdb-initialize "bbdb-autoloads")
345 ;(require 'bbdb-autoloads)
346 ;(require 'bbdb)
347 ;(require 'bbdb-com)
348 (bbdb-initialize 'gnus 'message)
350 (add-hook 'message-setup-hook 'bbdb-define-all-aliases)
351 (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
352 ;; complete names in To:
353 (add-hook 'message-mode-hook
354 (function (lambda()
355 (local-set-key (kbd "<tab>") 'bbdb-complete-name))))
357 (setq
358 ;; allow cycling when completing already complete addresses
359 bbdb-complete-name-allow-cycling t
360 bbdb-canonicalize-redundant-nets-p t
361 ;; save db wo/asking
362 ; bbdb-offer-save 1
363 ;; display layout
364 bbdb-display-layout 'multi-line
365 ;; number of lines in pop-up bbdb window
366 bbdb-pop-up-target-lines 2
367 bbdb-north-american-phone-numbers-p nil
368 bbdb-default-country "Ukraine")
372 ;;* Gnus soll im Article View eine dreigeteilte Ansicht haben:
373 ;;* |----------------------------|
374 ;;* | Summary |
375 ;;* |----------------------------|
376 ;;* | | |
377 ;;* | Article | *BBDB* |
378 ;;* |___________________|________|
379 ;(gnus-add-configuration
380 ; '(article
381 ; (vertical 1.0 ; erst ein verticaler Split
382 ; (summary 0.25 point) ; in dessen 1. Teil kommt der
383 ; ; Summary Buffer
384 ; (horizontal 1.0 ; im 2. Teil einen horizontalen
385 ; ; Split
386 ; (article 120) ; 1. Teil Article
387 ; ; Buffer
388 ; ("*BBDB*" 1.0))))) ; 2. Teil *BBDB*
389 ; ; Buffer
390 ;(setq bbdb-use-pop-up nil)
392 ;;;;;;;;;;;;;
393 ;; Functions
394 ;;;;;;;;;;;;;
396 ;; Moderating
397 (defun YSZ:award (name)
398 (let ((group (message-fetch-reply-field "Newsgroups")))
399 (cond
400 ((string-match "ntu-kpi.comp.software" group)
401 (progn
402 (YSZ:award-insert-stuff name)))
403 ((string-match "ntu-kpi.rec.games" group)
404 (progn
405 (YSZ:award-insert-stuff name)))
406 (t
407 (progn
408 (message-goto-body)
409 (insert "Ohrenel? V chujoy ehe-to nagrady stavit'??\n\n"))))))
411 (defun YSZ:award-insert-stuff (name)
412 (insert "--=off\n")
413 (insert moder-login "\n")
414 (insert moder-pass "\n")
415 (insert name)
416 (insert "\n")
417 (kill-line))
419 ;; Now playing
420 (setq now-playing-file "~/.song")
421 (defun prh:now-playing ()
422 "Returns the song now playing"
423 (when (file-exists-p now-playing-file)
424 (save-excursion
425 (goto-char (point-max))
426 ; (let ((coding-system-for-read 'utf-16-le)) (insert-file-contents now-playing-file)))))
427 (insert-file-contents now-playing-file)
428 (goto-char (point-max))
429 (newline))))
431 ;; Random citation line
432 (setq random-sig-directory "~/.sigs")
433 (defun prh:random-cite ()
434 "Adds to signature cite chosen randomly from `random-sig-directory'."
435 (interactive)
436 (when (file-exists-p random-sig-directory)
437 (let* ((files (directory-files random-sig-directory t ""))
438 (file (nth (random (length files)) files)))
439 (when file
440 (save-excursion
441 (goto-char (point-max))
442 (insert-file-contents file))))))
444 ;; This function is especially useful for message mode
445 (defun prh:intelligent-fill-paragraph ()
446 "Tries to guess the fill-prefix based on the current line and fills the paragraph"
447 (interactive)
448 (beginning-of-line)
449 (newline)
450 (let ((a (point)))
451 (end-of-line)
452 (if (search-backward-regexp
453 "^[ \t]*\\([>][ \t]*\\|[:#;|*][ \t]+\\|[a-zA-Z]+>[ \t]*\\)*"
454 a t)
455 (goto-char (match-end 0))
456 (beginning-of-line))
457 (set-fill-prefix)
458 (fill-paragraph nil)
459 (goto-char a)
460 (backward-delete-char 1)
461 (forward-paragraph)))
464 ;;;;;;;;;;
465 ;; Various hooks
466 ;;;;;;;;;;
468 (add-hook
469 'message-setup-hook
470 '(lambda ()
471 (let ((from-value (message-fetch-reply-field "From")))
472 ;; moderator's award launcher
473 (local-set-key [(control kp-add)] '(lambda () (interactive) (YSZ:award "+")))
474 (local-set-key [(control kp-multiply)] '(lambda () (interactive) (YSZ:award "*")))
475 (local-set-key [(control kp-subtract)] '(lambda () (interactive) (YSZ:award "-")))
476 (local-set-key [(meta !)] '(lambda () (interactive) (YSZ:award "!")))
477 )))
479 ;; for normal working of C-c C-c, instead of award overrides
480 (add-hook
481 'message-setup-hook
482 '(lambda ()
483 (local-set-key "\C-c\C-c" 'message-send-and-exit)))
485 (add-hook 'gnus-summary-mode-hook 'no-scroll-margin)
487 ;; for now-playing and citation lines
488 ;(add-hook 'message-setup-hook 'prh:random-cite)
489 ;(add-hook 'message-setup-hook 'prh:now-playing)
491 (global-set-key (kbd "<f9>") (fun-for-bind toggle-buffer "*Group*"))
493 ;;;;;;;;;;;;;;;;;;
494 ;; Autocompilation
495 ;;;;;;;;;;;;;;;;;;
497 (defun gnus-autocompile()
498 "compile itself if ~/.gnus"
499 (interactive)
500 (if (string= (buffer-file-name) (concat default-directory ".gnus"))
501 (byte-compile-file (buffer-file-name))))
502 ;(add-hook 'after-save-hook 'gnus-autocompile())
504 ;(setq smtpmail-debug-info t)
505 ;(setq smtpmail-debug-verb t)
Repositories maintained by Alexander Solovyov