Sunday, December 16, 2007

 

Emacs Tricks #7 - Use Gnus for Email

So now you have mail transferred in by fetchmail or getmail, delivered through spamassassin and Maildrop into a Maildir in your home directory on the hard drive in the laptop in front of you. You have Dovecot running providing a local IMAP service which can read and manipulate that Maildir. Now you can use Gnus as your mail reader with the nnimap back end.

As I've written in previous posts here, Gnus can do a lot of that stuff too, but not as flexibly. Also, if you do it with Gnus, you'll be waiting around a lot for it to finish. So we begin to configure Gnus by telling it that there are no sources of email it must go fetch, process, and/or otherwise transfer in.
(setq mail-sources nil)
Gnus is a news reader, but we're not using it to read news, just email, so we don't care about NNTP servers and their negotiations.
(setq gnus-nntp-server nil
gnus-read-active-file nil
gnus-save-newsrc-file nil
gnus-read-newsrc-file nil
gnus-check-new-newsgroups nil)
For a lot of Emacs, you can just load a package in your .emacs, learn a few commands, and then figure out the rest of it as you need to. With Gnus you will need to read the manual -- probably twice. I guess you don't absolutely need to understand select methods, but it would help if you understood the following configuration.
(setq gnus-select-method '(nnnil "")
gnus-secondary-select-methods
'((nnimap "localhost" (nnimap-address "localhost"))))
The basic idea is you have one news server from which you read messages with groups named like "alt.binaries.shatner", and other groups from stranger servers named like "nntp+poo.gnu.org:alt.binaries.shatner.commentary".

Like Emacs when you fired it up for the first time, the key bindings to Gnus are frustrating and confusing at first, but once you wire a few important things into your fingers, you'll be going faster than you could otherwise. Some things to think about as you're reading the manual: first, understand that there are *Group*, *Summary*, and *Article* buffers, and that these all have different key maps. Second, you can see all the messages with / o in the *Summary* buffer. Third, you can 'expire' a message, in which case it goes away after a 'while', with E in the summary buffer. To truly delete it immediately use B DEL.

I get a lot of speed out of Gnus. My time per day on email in Evolution with IMAP was about 2 hours. In Evolution with fetchmail (etc.) and Maildir was about 1 hour. In Mutt with fetchmail into Maildir was about 40 minutes. In Mutt with fetchmail sorting bulk messages, 30 minutes per day. Switching to Gnus, still about 30 minutes. With Gnus and scoring, about 20 minutes to read email and 20+ RSS feeds; being able to use prefix arguments and keyboard macros means my mail commands scale. I'm not sure you can get that unless you actually experience it, which I hope you will.

Once you've read the manual and have started to hack, have a look at this:
(setq gnus-thread-sort-functions
'(gnus-thread-sort-by-number
gnus-thread-sort-by-date
gnus-thread-sort-by-total-score))
(setq gnus-summary-line-format
"%U%R%z %d %I%(%[%-25,25n%]%) %s\n")

(gnus-add-configuration
'(article
(horizontal 1.0
(vertical 60 (group 1.0))
(vertical 1.0
(summary 0.20 point)
(article 1.0)))))

(gnus-add-configuration
'(summary
(horizontal 1.0
(vertical 60 (group 1.0))
(vertical 1.0 (summary 1.0 point)))))
Next entry: sending mail with msmtp.

Future entry: nnrss.

Labels: , ,


Comments:
How are you keeping copies of your sent items with this method. I seem to be having difficulty setting that up. I want them saved in a Sent Items folder.
 
(setq gnus-message-archive-method '(nnimap "localhost"))
(setq gnus-message-archive-group "nnimap+localhost:Sent")
 
Hey, that's easy. The only thing that could improve on that is if they showed up already marked as read in the Sent folder.
 
Oh:

(setq gnus-gcc-mark-as-read t)
 
I got everything working up to dovecot (even telnet-ed in to localhost 143 to verify dovecot was working), but when I fire up gnus, all I see is

*: nndraft:queue
*: nndraft:drafts

'F' bring up the login to the imap server, but I can't see any of the messages in ~/Maildir

Any sage advice?
 
Look at all the groups with 'A A'. Subscribe to the ones you want to see (especially INBOX) with 'u'. That should help.
 
Post a Comment

Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?