A note on archiving Gmail messages in Mutt
A while ago I switched to Mutt for all of my email needs. I have a mix of regular IMAP accounts and a few Gmail powered accounts set up. The Gmail accounts have always been a thorn in my side due to an early misconception I had about the All Mail folder and archiving. Below is my initial problem, solution and what I found to be the consistent behaviour of a Mutt + Gmail setup.
In Mutt, an easy way to archive email is to set up a macro which moves that email to an archive folder, or in the case of Gmail, the All Mail folder.
Note: These macros assume that you have an archive folder set up. I also use OfflineImap to map my Gmail All Mail folders to Archive folders for consistency.
In a normal IMAP instance, email which is in the inbox only exists in the inbox. In Gmail, email in any folder will show up in your archive/all mail folder. The problem this creates is that when you "Archive" and email, that message is moved to the All Mail folder and, locally in Mutt, you see duplicate emails in All Mail. At first I thought this was a problem and had macro to purge that email from the inbox by unsetting the trash folder and then deleting it.
This would leave the message in the All Mail folder and remove it from my inbox. This method is full of issues that were very annoying.
After some research I've found that the normal archive route that produces duplicates is in fact ok. Duplicates will exist for two syncs up to Gmail. One that sends them up, Gmail then removes the detected duplicates, and then another OfflineImap sync to bring back down those changes.
No more worries about duplicate emails. Just need to dig in and do more testing to get the behaviour down.
My hope is that this post will help others that have run across the same odd behaviour and share the duplication concerns. Good luck in your Mutt + Gmail endeavours!