Re: [PATCH] emacs: call "notmuch tag" only once when archiving a thread
authorMark Walters <markwalters1009@gmail.com>
Mon, 9 Jan 2012 11:31:21 +0000 (11:31 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:49 +0000 (09:41 -0800)
ac/8781cbd5628b290d2ec553b677285ba3542584 [new file with mode: 0644]

diff --git a/ac/8781cbd5628b290d2ec553b677285ba3542584 b/ac/8781cbd5628b290d2ec553b677285ba3542584
new file mode 100644 (file)
index 0000000..601ffca
--- /dev/null
@@ -0,0 +1,136 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 50965431FD0\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Jan 2012 03:31:35 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\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 SwJdhzxot2+o for <notmuch@notmuchmail.org>;\r
+       Mon,  9 Jan 2012 03:31:34 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A00D7431FB6\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Jan 2012 03:31:34 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1RkDRi-0002Ag-6K; Mon, 09 Jan 2012 11:31:31 +0000\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+       helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1RkDRh-0005rz-S8; Mon, 09 Jan 2012 11:31:22 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, Aaron Ecay <aaronecay@gmail.com>\r
+Subject: Re: [PATCH] emacs: call "notmuch tag" only once when archiving a\r
+       thread\r
+In-Reply-To: <20120109011259.GD20796@mit.edu>\r
+References: <1325615346-8302-1-git-send-email-jani@nikula.org>\r
+       <m2hb09kj0m.fsf@gmail.com> <87fwftao1b.fsf@nikula.org>\r
+       <m262glk82m.fsf@gmail.com> <20120109011259.GD20796@mit.edu>\r
+User-Agent: Notmuch/0.10.2+172~g60f099b (http://notmuchmail.org) Emacs/23.3.1\r
+       (i486-pc-linux-gnu)\r
+Date: Mon, 09 Jan 2012 11:31:21 +0000\r
+Message-ID: <87wr91f6ye.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 380c5fc64b1cdd4bf720bece40193094 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.7\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.7 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+       *      domain\r
+       *  0.6 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: notmuch@notmuchmail.org\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: Mon, 09 Jan 2012 11:31:35 -0000\r
+\r
+\r
+> There's been quite a bit of discussion on fixing this properly.  See,\r
+> for example\r
+> id:"CAH-f9WsPj=1Eu=g3sOePJgCTBFs6HrLdLq18xMEnJ8aZ00yCEg@mail.gmail.com".\r
+> The gist is that we need to include message IDs (or document IDs) in\r
+> the search output and use these in tagging operations, rather than the\r
+> unstable thread:XXX queries.  Unfortunately, actually fixing this got\r
+> stalled since adding this information the text format is a fool's\r
+> errand (having been the fool, I can say this!), so we need to switch\r
+> Emacs over to using the JSON search format first.  However, once\r
+> that's done, it's a relatively simple change.\r
+\r
+I will just mention a different possible solution to this problem. I\r
+think it is probably more hassle than its worth but just in case someone\r
+sees how to do it nicely. \r
+\r
+The idea is to try and put the race-free solution into the command-line\r
+notmuch rather than the emacs part.\r
+\r
+I will just consider one race to start with: the race in notmuch\r
+search/notmuch tag. notmuch search gives us just the thread-ids and what\r
+is in that thread can change. So we could ask for a "cookie" (some short\r
+unique identifier) and notmuch itself would store the state of its\r
+output (i.e., the thread-ids together with the message-ids and the\r
+matched message-ids).\r
+\r
+Then notmuch tag could be called with this cookie to say "apply this tag\r
+to the threads as they were at cookie.\r
+\r
+example use\r
+notmuch search --cookie <query>\r
+prints a cookie followed by the output of the search\r
+\r
+notmuch tag --cookie=cookievalue +sometag matched-thread:id .. \\r
+                                 all-thread:id .. <other search terms>\r
+\r
+and notmuch would replace the matched-thread:id by the (matching)\r
+message-ids in thread it stored at time cookievalue and all-thread by\r
+all the messages at time cookievalue.\r
+\r
+The nice feature is that this makes it easy for all clients to be race\r
+free (not just emacs). The backend has the information to hand: there is\r
+no encoding and decoding (via text or JSON) so storing message-ids etc\r
+is simpler.  It also means that if notmuch wants to use document-ids\r
+internally it can: it does not become a public interface.\r
+\r
+The downside is trying to do the argument parsing in c and we have do\r
+some reference counting or something to delete the cookies state at some\r
+point.\r
+\r
+Anyway it's just a thought.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r