;; Gnus configuration file. (Download)
(require 'bbdb) (bbdb-initialize 'gnus 'message)
;; ~/Mail folders are annoying (setq gnus-select-method '(nnml "" (nnml-directory "~/.mail/") (nnml-active-file "~/.mail/active")))
;; Don't do this, it's more trouble than it's worth. And plenty of examples and ;; tutorials gave me the impression early on that this is required for importing ;; emails stored in maildir format. It's not. It's only for continuing to use ;; maildirs for storing your email, and there are very few advantages to that ;; over nnml. ;; ;; If you want to import an existing maildir just do "G D" and open the folder, ;; then mark "M P b" and spool "B r". Just be sure to select the correct backend ;; instead of nneething. And be careful not to select . and .. when marking the ;; files (M-# to unmark). ;; ;; Since you probably won't have split rules for sent emails remember you can ;; just copy marked emails with B c. ;; (add-to-list 'gnus-secondary-select-methods '(nnmaildir "maildir" (directory "~/maildir/"))) ;; Say goodbye to your maildir if you do this ;; (setq mail-source-delete-incoming t) ;; Stops sent emails appearing as new (setq gnus-gcc-mark-as-read t)
;; Using procmail with a spool means you can use display-time-mail-file and ;; display-time to see when you have new mail (setq mail-sources '((file :path "/var/spool/mail/mat") ;; Again, don't do this if you're just importing ;; (maildir :path "~/maildir/" :subdirs ("cur" "new")) ))
;; Stick these in your .emacs since this file isn't loaded until gnus is ;; (display-time) ;; (setq display-time-mail-file "/var/spool/mail/mat") ;; (setq display-time-use-mail-icon t) ;; (setq display-time-mail-icon '(image :type xpm :file "/home/mat/pictures/mail.xpm" :ascent center)))) ;; Works better than the default of gnus-gather-threads-by-references (setq gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject)
;; Controls how hungry the thread matching is ;; (setq gnus-summary-gather-subject-limit 'fuzzy) ;; I duplicated my 10000+ emails so many times when testing out new split ;; methods, had to use sed to remove the Xref headers Gnus inserts so I could ;; use fdupes to remove the duplicates and re-import everything. Speaking of ;; fdupes, be sure you remember to use the -f option, otherwise you'll end up ;; deleting every file that has or is itself a duplicate. Effectively losing ;; all the emails you accidentally duplicated. ;; ;; This variable would have spared me all that trouble. Incidentally commenting ;; code after an ordeal like this is quite therapeutic. (setq nnmail-crosspost nil)
;; If you store contacts in the bbdb you have the potential for some very clever ;; whitelisting. Simply add a new field to each contact (^O) called gnus-private ;; (or gnus-public for newgroups) and enter the group you want mail from that ;; contact to be put in. ;; ;; The whitelist comes first, followed by the rules below in order, stopping ;; when a mail matches. Matching is slightly odd e.g. "@ebuyer" won't match ;; orders@ebuyer.com but "Ebuyer" will match "Ebuyer Customer Service". Word ;; boundaries? ;; ;; Interestingly, if you accidentally name the last rule something like: ;; ;; ("junk") instead of just "junk" ;; ;; mail that gets through all the rules without a match gets placed in the ;; "bogus" group, a default catch-all rule. (setq nnmail-split-methods 'bbdb/gnus-split-method bbdb/gnus-split-nomatch-function 'nnmail-split-fancy nnmail-split-fancy `(| ("Subject" "Notification of Spam Bot Attempt" "bots") ("from" "forum-mods@gentoo.org" "forums") ("from" "admin@forums.introversion.co.uk" "forums") ("from" "Stella Awards" "stella") ("from" "webmaster@improveverywhere.com" "improv") ("from" "introversion.co.uk" "default") ("from" "brad@bradsucks.net" "bradsucks") ("to" "gentoo-announce" "gentoo-announce") ("x-spam-flag" "YES" "spam") ("from" "primehosting" "default") ("from" "magnatune.com" "magnatune") ("from" "amazon.\\(com\\|co.uk\\)" "amazon") ("from" "Ebuyer" "ebuyer") ("from" "play.com" "play") ("from" "service@paypal.co.uk" "paypal") ("to" "root@localhost.localdomain" "system") ;; ("to" "webmaster@preys-world.com" "preys-world") ("to" "dadsemail@blueyonder.co.uk" "ebay") "junk"))
;; Don't make email expirable by default (remove-hook 'gnus-mark-article-hook 'gnus-summary-mark-read-and-unread-as-read) (add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
;; Only mails in these groups will expire, meaning they'll be deleted after a ;; week so long as I've read them. (setq gnus-auto-expirable-newsgroups "junk\\|forums\\|gentoo-announce\\|bradsucks\\|bots\\|system\\|nnrss:.*")
;; Neat feature, set things up for outgoing mail based on the current mail ;; group. So much better than using alternates and send-hooks in mutt. (setq gnus-posting-styles '(("ebay" ("From" "William Mawdsley <dadsemail@blueyonder.co.uk>") ("User-Agent" "Gnus/5.11 Emacs/23.0.0.1"))
(".*" ("From" "Matthew Mawdsley <myemail@blueyonder.co.uk>") ("User-Agent" "Gnus/5.11 Emacs/23.0.0.1"))))
;; No archive method, just stick them in a group (setq gnus-message-archive-method "")
;; Place outgoing emails in specific groups depending on the current group. ;; Pretty much gnus-posting-styles again really. (setq gnus-message-archive-group '(("ebay" "sent.dad") (".*" "sent.mat")))
;; Topics are a nice way to group common groups, handy if you handle other ;; people's email and you want a separate counter for your mail. You can even do ;; hierarchies: ;; ;; [ Gnus -- 0 ] ;; 0: nndraft:queue ;; 0: nndraft:drafts ;; [ junk -- 0 ] ;; 0: bots ;; 0: junk ;; 0: spam ;; [ mat -- 0 ] ;; 0: default ;; 0: college ;; 0: magnatune ;; 0: preys-world ;; 0: forums ;; 0: system ;; 0: sent.mat ;; [ lists -- 0 ] ;; 0: bradsucks ;; 0: gentoo-announce ;; 0: stella ;; [ feeds -- 0 ] ;; 0: nnrss:The Register ;; 0: nnrss:Slashdot ;; 0: nnrss:Preys-World ;; 0: nnrss:The Perry Bible Fellowship ;; [ dad -- 0 ] ;; 0: ebay ;; 0: paypal ;; 0: sent.dad ;; [ shops -- 0 ] ;; 0: amazon ;; 0: ebuyer ;; 0: play ;; ;; Nice and concise, collapsable too. (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
;; Pressing tab by accident gets old, this disables the command completely (put 'gnus-topic-indent 'disabled "It is disabled because you disabled it.")
;; Because Gnus loads after everything else you might find that it doesn't ;; fully match your colour theme, this fixes it. (add-hook 'gnus-group-mode-hook 'color-theme-charcoal-black)
;; Format RSS feed titles nicely (add-hook 'gnus-summary-mode-hook (lambda () (if (string-match "^nnrss:.*" gnus-newsgroup-name) (progn (make-local-variable 'gnus-show-threads) (make-local-variable 'gnus-article-sort-functions) (make-local-variable 'gnus-use-adaptive-scoring) (make-local-variable 'gnus-use-scoring) (make-local-variable 'gnus-score-find-score-files-function) (make-local-variable 'gnus-summary-line-format) (setq gnus-show-threads nil) (setq gnus-article-sort-functions 'gnus-article-sort-by-date) (setq gnus-use-adaptive-scoring nil) (setq gnus-use-scoring t) (setq gnus-score-find-score-files-function 'gnus-score-find-single) (setq gnus-summary-line-format "%U%R%z%d %I%(%[ %s %]%)\n")))))
;; Gnus has built in support for RSS feeds, just hit "G R" and enter the feed ;; URL. Unfortunately Gnus will check RSS feeds everytime you check your email, ;; which is very impolite. ;; ;; To get around this, you set nnrss into local mode, which will fetch news ;; from locally stored RSS feeds. (setq nnrss-use-local t)
;; Wait 2 hours between polls (defvar my-nnrss-check-group-interval 7200 "*Number of seconds between retrieval of RSS feeds.")
(defvar my-nnrss-check-group-time (- (time-to-seconds (current-time)) my-nnrss-check-group-interval) "Time of last RSS retrieval.")
;; Calls an external script at the polling interval which downloads the feeds ;; and stores them ready for checking. You generate this script by adding the ;; feeds you want to check and running nnrss-generate-download-script in an ;; empty buffer and saving it. (defadvice nnrss-check-group (before my-nnrss-check-group activate) "Maybe call shell script to fetch RSS feeds. Feeds are fetched every `my-nnrss-check-group-interval' seconds." (when (> (- (time-to-seconds (current-time)) my-nnrss-check-group-time) my-nnrss-check-group-interval) (call-process "~/.bin/nnrss.sh") (setq my-nnrss-check-group-time (float-time))))
;; nnrss-generate-download-script didn't work for me, so here's the format of ;; the download script: ;; ;; #!/bin/sh ;; WGET=wget ;; RSSDIR='/home/mat/.mail/rss/' ;; $WGET -q -O "$RSSDIR"/'The Register.xml' 'http://www.theregister.co.uk/headlines.rss' ;; $WGET -q -O "$RSSDIR"/'The Perry Bible Fellowship.xml' 'http://pbfcomics.com/feed/feed.xml' ;; $WGET -q -O "$RSSDIR"/'Preys-World.xml' 'http://http://pwv3.preys-world.com/feeds/main.xml' ;; ;; The only thing to be careful of is the filename you save each feed to, it ;; must be exactly the same as the title you've given the feed. ;; nnrss-group-alist contains all the info you need to make the script. (require 'cl) (require 'gnus) (require 'nnrss) (require 'browse-url)
;; Hit C-u C-Enter to open an RSS article with browse-url (firefox), awesome. ;; Hit C-Enter to open an RSS article with w3m, but switch back to the summary ;; buffer straight away. (defun browse-nnrss-url (arg) (interactive "p") (let ((url (assq nnrss-url-field (mail-header-extra (gnus-data-header (assq (gnus-summary-article-number) gnus-newsgroup-data)))))) (if url (if (= arg 4) (browse-url (cdr url)) (progn (setq summary-buffer (current-buffer)) (setq browse-url-browser-function 'w3m-goto-url-new-session) (browse-url (cdr url)) (setq browse-url-browser-function 'browse-url-generic) (switch-to-buffer summary-buffer))) (gnus-summary-scroll-up arg))))
(add-hook 'gnus-summary-mode-hook (lambda () (define-key gnus-summary-mode-map (kbd "C-<return>") 'browse-nnrss-url)))
(add-to-list 'nnmail-extra-headers nnrss-url-field)