[notmuch] Some thoughts about notmuch sync with other agents
authorPaul R <paul.r.ml@gmail.com>
Wed, 27 Jan 2010 14:16:07 +0000 (15:16 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:03 +0000 (09:36 -0800)
c0/8a3befc4bbafa43f814280d3768fa0d734c169 [new file with mode: 0644]

diff --git a/c0/8a3befc4bbafa43f814280d3768fa0d734c169 b/c0/8a3befc4bbafa43f814280d3768fa0d734c169
new file mode 100644 (file)
index 0000000..53470fc
--- /dev/null
@@ -0,0 +1,228 @@
+Return-Path: <SRS0=a4S0=JM=plane.gmane.org=public@srs.perfora.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C4B6B431FBC\r
+       for <notmuch@notmuchmail.org>; Wed, 27 Jan 2010 06:16:28 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.001\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
+       tests=[BAYES_50=0.001] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id n+87boE0Yp5n for <notmuch@notmuchmail.org>;\r
+       Wed, 27 Jan 2010 06:16:27 -0800 (PST)\r
+Received: from mout.perfora.net (mout.perfora.net [74.208.4.194])\r
+       by olra.theworths.org (Postfix) with ESMTP id D24E4431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 27 Jan 2010 06:16:27 -0800 (PST)\r
+Received-SPF: pass (mxus1: domain of plane.gmane.org designates 80.91.229.3 as\r
+       permitted sender) client-ip=80.91.229.3;\r
+       envelope-from=public@plane.gmane.org; helo=plane.gmane.org; \r
+Received: from plane.gmane.org (plane.gmane.org [80.91.229.3])\r
+       by mx.perfora.net (node=mxus1) with ESMTP (Nemesis)\r
+       id 0LewLP-1O9FFF1ZXz-00q87P for notmuch@notmuchmail.org;\r
+       Wed, 27 Jan 2010 09:16:26 -0500\r
+Received: from public by plane.gmane.org with local (Exim 4.63)\r
+       (envelope-from <public@plane.gmane.org>) id 1Na8gk-0006h3-In\r
+       for notmuch@notmuchmail.org; Wed, 27 Jan 2010 15:16:10 +0100\r
+Received: from mail-ew0-f224.google.com ([209.85.219.224])\r
+       by plane.gmane.org with esmtp (Exim 4.63)\r
+       (envelope-from <paul.r.ml@gmail.com>) id 1Na8gf-0006e8-F2\r
+       for public-notmuch-gxuj+Tv9EO5zyzON3hdc1g@plane.gmane.org;\r
+       Wed, 27 Jan 2010 15:16:05 +0100\r
+Received: by ewy24 with SMTP id 24so1147591ewy.26\r
+       for <notmuch-gxuj+Tv9EO5zyzON3hdc1g@public.gmane.org>;\r
+       Wed, 27 Jan 2010 06:16:11 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:received:from:to:subject:date\r
+       :message-id:user-agent:mime-version:content-type\r
+       :content-transfer-encoding;\r
+       bh=3zfT1AGMFeWwOGcjt07ZYxPE99oKFWRWkJypL7mkJRY=;\r
+       b=He/zQ4KjCWjNU8d7bVTWZMGAaAaKdikRSQemR8EM6VZe9G97KkyUd/TgDRxECBAvi2\r
+       vDPxAScvO+cv4njU+wWVqYsE8hapxVjrs9DB+dqjx+OGF5hzUJtkXgva5sqL5B+dm1l4\r
+       GetysWU9XgF4qPJevOq0b5mPBMwwzaxeJ0HbU=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=from:to:subject:date:message-id:user-agent:mime-version\r
+       :content-type:content-transfer-encoding;\r
+       b=JbzDQW7Vh8TW0NmGjx2yq3VYVDUlx6rc81AKsIScsd0bn6ZnoIMBhXqSFWEIbDLUZA\r
+       oyypGEhJTHs0WHUtAMr7B5pmDiF/9fU9V7kF1k81s3SHAF5SpS0IWJtwBUxmj7aMCK68\r
+       zE2ivGAaILxmV0UfK5kSlElhXwJgR8FpatlGM=\r
+Received: by 10.213.1.18 with SMTP id 18mr2552002ebd.17.1264601770650;\r
+       Wed, 27 Jan 2010 06:16:10 -0800 (PST)\r
+Received: from ubuT42 (vil35-2-82-227-204-220.fbx.proxad.net [82.227.204.220])\r
+       by mx.google.com with ESMTPS id 13sm5982192ewy.1.2010.01.27.06.16.09\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Wed, 27 Jan 2010 06:16:09 -0800 (PST)\r
+From: Paul R <paul.r.ml@gmail.com>\r
+To: notmuch <public-notmuch-gxuj+Tv9EO5zyzON3hdc1g@plane.gmane.org>\r
+Date: Wed, 27 Jan 2010 15:16:07 +0100\r
+Message-ID: <87wrz3zl94.fsf@gmail.com>\r
+User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Mailman-Approved-At: Fri, 29 Jan 2010 16:40:03 -0800\r
+Subject: [notmuch] Some thoughts about notmuch sync with other agents\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 27 Jan 2010 14:16:28 -0000\r
+\r
+\r
+\r
+Hi,\r
+\r
+before going into details, I'd like to tell you how much I like the\r
+notmuch workflow, thank you for producing this nice piece of software !\r
+\r
+Like most potential users, I can not really fully jump into notmuch\r
+because of the current synchronisation issues with others MUA. One may\r
+or may not like IMAP for good reasons, the fact is that it is here and\r
+has allowed users to read mails from various places and terminals,\r
+keeping important information synced. So I think that notmuch will have\r
+to live with that, and provide what is required to integrate smoothly\r
+into this environment. Redefining a new mail retrieval protocol and\r
+a mail storing format are both really exciting projects, but they are\r
+projects on their own that could only distract notmuch from its most\r
+beautiful goal : giving *today* users the power to process mail in an\r
+efficient way.\r
+\r
+As you see, I advocate a NotMuch <-> IMAP synchronisation ASAP :)\r
+\r
+At the moment, notmuch input are mail-as-file + user-defined tags.\r
+OfflineIMAP allows to do the IMAP <-> mail-as-file transition, in both\r
+directions, mail-as-file being namely MailDir. So we can simply aim at\r
+a NotMuch <-> MailDir synchronisation, offlineimap will take care of\r
+IMAP itself.\r
+\r
+Of course, my proposal does not require to implement any MailDir\r
+specific logic inside NotMuch, but rather describes how should notmuch\r
+evolve to allow easy third-party-tool jobs.\r
+\r
+\r
+Preliminary thoughts :\r
+----------------------\r
+\r
+First of all, processing mail with MUA involves some simple logic that\r
+is shared by most MUA. This is about receiving *new* mails, *reading*\r
+mail, *replying* to mail and so on... IMHO, this really belongs to the\r
+mail processing logic and not to the user logic. Hence my first\r
+request :\r
+\r
+  1: Don't use user tags space to store MUA flags.\r
+\r
+     That means no more "seen", "unread", "replied" as tags. These are\r
+     MUA processing *flags*, that must belong to an established set.\r
+     Tags, on the other hand, are user-land information. So no more\r
+     [seen, replied, grandma, important] tag sets :)\r
+\r
+Once this is done, notmuch will know, in a robust a predictable way,\r
+what happened to a mail. Simply put, NotMuch will store and expose MUA\r
+flags (Passed, Replied, Seen, Trashed, Draft, and Flagged [1]). For each\r
+<flag>, notmuch should associate a <flag>_synced flag. When changing\r
+<flag> from notmuch, it should set the <flag>_synced bit to 0. These are\r
+MUA mail flags.\r
+\r
+Additionally, in a third =C2=AB space =C2=BB, notmuch should store its =C2=\r
+=AB new =C2=BB\r
+bit, as well as a =C2=AB missing =C2=BB bit probably. Again, this is neithe=\r
+r MUA\r
+logic or user logic, so this should not interfer with user\r
+classification facility provided by tags, nor with MUA flags. It,\r
+really, is something else, let's name it "status". Once this is done,\r
+the 'notmuch new' command should find new mails and set the 'new' bit\r
+for them, and find the missing mails and set the 'missing' bit for them.\r
+This will allow for robust external processing.\r
+\r
+Finally, notmuch should provide a switch to output a list of filenames\r
+to stdout and to process a list of filenames from stdin.\r
+\r
+\r
+NotMuch <-> MailDir synchronisation :\r
+-------------------------------------\r
+\r
+Provided the behaviour described above, notmuch <-> MailDir\r
+synchronisation could be done fully externally, by a 'notmuch-maildir'\r
+adapter.\r
+\r
+Here is some pseudo code, that could be wrapped into a single\r
+'notmuch-sync' command. The | are unix stream pipes, and everything\r
+should be on a single line.\r
+\r
+# 1/ Sync from NotMuch to MailDir\r
+\r
+    notmuch list flags:(seen and not seen_synced)=20\r
+      | notmuch-maildir --mark-mail seen\r
+      | notmuch move --stdin\r
+      | notmuch set flags:+seen_synced --stdin\r
+\r
+The output of the first command would be a list of filenames for mails\r
+'seen' since last sync. The second one, an external notmuch--maildir\r
+helper, would propagate this logic to the MailDir store (easy, this is\r
+simply a rename), and output the list of (old-name ! new-name). Then\r
+notmuch would use this information, via a generic 'move' switch, to know\r
+that mail has been moved, and would output the list of the new places.\r
+Finaly, notmuch would set the seen_synced flag.\r
+\r
+Same would apply for the Replied, Trashed, Flagged and Passed flags.\r
+\r
+# 2/ Then lets do the MailDir <-> IMAP sync\r
+\r
+     offlineimap\r
+\r
+... done ! that was easy :)\r
+\r
+# 3/ notmuch new\r
+\r
+     notmuch new\r
+\r
+At this point, notmuch should set the 'new' or the 'missing' status bit\r
+to the mails. Let's forget how to deal with the missing bit, that should\r
+be easy to do.\r
+\r
+# 4/ Sync from MailDir to NotMuch\r
+\r
+  notmuch list status:new=20\r
+   | notmuch-maildir --filter seen\r
+   | notmuch set flags:+seen+seen_synced --stdin\r
+\r
+First command outputs newly discovered mail. Second one reads stdin and\r
+output only files that are already seen (again, this is as easy as\r
+a filter based on a regular expression). Third one reads stdin and\r
+applies the seen and seen_synced flags.\r
+\r
+Same applies for the Replied, Trashed, Flagged and Passed flags.\r
+\r
+\r
+Conclusion:\r
+-----------\r
+\r
+As we have seen, this would allow most IMAP <-> MailDir <-> NotMuch\r
+synchronisation, without having to implement any kind of\r
+MailDir-specific logic inside notmuch. In fact, this notmuch-maildir\r
+helper would be a simple script, and we could imagine doing similar\r
+script for other stores, without having to touch the core of notmuch.\r
+\r
+\r
+That was a long mail indeed, thank you for reading ! I'm waiting for\r
+your comments.\r
+\r
+\r
+\r
+Footnotes:=20\r
+[1]  http://cr.yp.to/proto/maildir.html\r
+\r
+--=20\r
+  Paul\r
+\r