1 GMail has become slow
The GMail redesign was a while ago. I don't care much about the visual
changes. The main thing I dislike is how sluggish the interface has
become. Interacting with it no longer feels snappy and regularly I run
beforeunload handlers warning me I might lose data
when attempting to close the tab.
Since the place I work at uses GSuite and there's a lot of email to go through in the morning I decided to stop using the GMail webclient.
The rest of this page describes my personal email setup.
2 Have you accepted GNU Emacs as your lord and savior?
I have and therefore decided on using Notmuch1. It has an official GNU Emacs client and it's simplicity makes it interesting and fun to use and configure. Because it's pretty minimalist in it's design an additional program is needed to synchronize your mail. The most popular choice for this is probably OfflineIMAP.
OfflineIMAP will synchronize mail between GMail and a local maildir. Plenty can be found online on how to configure OfflineIMAP with GMail. Here's a basic configuration that downloads a couple of IMAP folders.
The referenced Python file is responsible for parsing my PGP encrypted Gnus authinfo file. This contains the password used to connect to IMAP.
So I don't have to type my password often I set
# cache for 24 hours default-cache-ttl 86400 max-cache-ttl 86400
Now that OfflineIMAP has downloaded a copy of my mail into a local maildir we need to index it with Notmuch. This makes it searchable. Indexing is accomplished by simply running
$ notmuch new
In Notmuch email is organized by tags. We can tell Notmuch to tag all emails that match some search query:
$ notmuch tag +inbox -archived -- folder:INBOX
This goes through all mail in the INBOX folder, removes the
tag and adds the
inbox tag. This way we essentially put all mail in
our GMail INBOX (from here on when I refer to INBOX I mean the remote
GMail INBOX) in our Notmuch "inbox".
I try to achieve basic 2-way sync. Meaning that if I archive mail in
the GMail webclient it will sync locally as well. Hence the
3.4 Avoiding the huge INBOX of death
Notmuch does not modify your local mail2. You may be removing
inbox tags from local emails but your remote inbox will never be
modified. This eventually leads to a huge INBOX.
In order to avoid this and keep our INBOX clean we can:
- search for mail tagged with
archivedand move it to the archived maildir folder
- search for mail tagged with
inboxand move it to the inbox maildir folder
- run OfflineIMAP
4 Putting it all together
I implement the previous concepts in a Bash script. Whenever I want to download mail I run the script manually.
- moves mail to the correct maildirs
- removes deleted mail
- indexes mail with
- tags mail based on what maildir folder they're in
- tags mail low-priority mail, i.e. mailing lists
Moving mail to the correct maildirs ensures that when mail is archived
in Notmuch it's also archived remotely when
Removing mail tagged with
deleted is necessary because when
composing a draft Notmuch creates a new
draft when saving and adds
deleted to previously saved drafts. This gives some sort of
rudimentary version control but as someone who saves draft mail often
often it leads to a lot of clutter.
The last steps in the script tags mail based on what maildir they're
in and their content. The
--lastmod trick allows this tag operation
to happen quickly. Without it Notmuch would reapply the tags to all
mail. This can take a while with a large amount of mail. Every time
Notmuch makes some modification to its database it increments a
revision number. By storing the revision number before running
notmuch new we can make Notmuch tag only new mail.
5 GNU Emacs
My Emacs configuration is not very special. We have software that
sends email with non-break spaces which doesn't render nicely in
replace-unicode-no-break-space replaces those with regular
spaces before displaying the message.
notmuch-fcc-dirs defines what folder sent mail gets put into and how
notmuch-mua-user-agent-full puts back the user-agent string which
removed for dubious "security" reasons. This way people know they're
nowhere near as cool as you are when they are reading your mail.