;; -*- 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)))))
;;}}}