Re: [PATCH] Automatically exclude tags in notmuch-show
authorAustin Clements <amdragon@MIT.EDU>
Fri, 20 Jan 2012 17:18:01 +0000 (12:18 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:50 +0000 (09:42 -0800)
4d/f5db3172e8fd5c25625912af1f82e1d36a75e3 [new file with mode: 0644]

diff --git a/4d/f5db3172e8fd5c25625912af1f82e1d36a75e3 b/4d/f5db3172e8fd5c25625912af1f82e1d36a75e3
new file mode 100644 (file)
index 0000000..72b6120
--- /dev/null
@@ -0,0 +1,127 @@
+Return-Path: <amdragon@mit.edu>\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 A7153431FAF\r
+       for <notmuch@notmuchmail.org>; Fri, 20 Jan 2012 09:18:23 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 c+pLJgP7PG66 for <notmuch@notmuchmail.org>;\r
+       Fri, 20 Jan 2012 09:18:23 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0724C431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 20 Jan 2012 09:18:22 -0800 (PST)\r
+X-AuditID: 1209190e-b7f7c6d0000008c3-b9-4f19a1de49c6\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id B2.18.02243.ED1A91F4; Fri, 20 Jan 2012 12:18:22 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0KHIMB2026348; \r
+       Fri, 20 Jan 2012 12:18:22 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0KHILSm012234\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 20 Jan 2012 12:18:22 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1RoI6D-0006H2-Bm; Fri, 20 Jan 2012 12:18:01 -0500\r
+Date: Fri, 20 Jan 2012 12:18:01 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH] Automatically exclude tags in notmuch-show\r
+Message-ID: <20120120171801.GA16740@mit.edu>\r
+References: <874nvric7c.fsf@qmul.ac.uk>\r
+       <1327010583-23954-1-git-send-email-markwalters1009@gmail.com>\r
+       <20120119225910.GT16740@mit.edu> <871uqvgrnm.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <871uqvgrnm.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT1723UNLf4ModdYvVc3ksrt+cyezA\r
+       5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZUz6MoWtoF2oYubq6awNjPP5uhg5OSQETCSW\r
+       bVjIBGGLSVy4t56ti5GLQ0hgH6PEwf6HTBDOBkaJ1i2rmSGck0wSLxd2sUA4Sxgl5l5axA7S\r
+       zyKgKnF18UdGEJtNQENi2/7lYLaIgI7E7UMLwGqYBaQlvv1uBtsnLGAvMXnpYmYQmxeo5vCs\r
+       l+wQQ1cwSrR3b2WFSAhKnJz5hAWiWUvixr+XQM0cYIOW/+MACXMC7brzYxpYiaiAisSUk9vY\r
+       JjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0jfVyM0v0UlNKNzGCAptT\r
+       km8H49eDSocYBTgYlXh4OV0l/IVYE8uKK3MPMUpyMCmJ8krOk/QX4kvKT6nMSCzOiC8qzUkt\r
+       PsQowcGsJMJb1gWU401JrKxKLcqHSUlzsCiJ86ppvfMTEkhPLEnNTk0tSC2CycpwcChJ8NYC\r
+       I1hIsCg1PbUiLTOnBCHNxMEJMpwHaHgDSA1vcUFibnFmOkT+FKOilDivE0hCACSRUZoH1wtL\r
+       PK8YxYFeEeaNAaniASYtuO5XQIOZgAZ7NImBDC5JREhJNTBmxWb2x29cFnK66b7Ghk/ep16o\r
+       8J3P3RKduVTVofGZV3VdCctbHzsRpYNiP7bPXrBmvUBiQs4kKfEXj+e1Trq6X9+Q+bvMK8dL\r
+       Mfx6Xtc3TMqOs36/Rmiae7hwlfuFqNRZ5zXN4kTWyL17uDxFZMctY86vNyU54kvfCb2a9Idz\r
+       nwebL8eVrOlKLMUZiYZazEXFiQDXLSNRFwMAAA==\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: Fri, 20 Jan 2012 17:18:24 -0000\r
+\r
+Quoth Mark Walters on Jan 20 at 12:10 am:\r
+> \r
+> Ok Having said this is trivial I have found a problem. What should\r
+> notmuch do if you do something like\r
+> \r
+> notmuch show id:<some-id>\r
+> and that message is marked with a deleted tag? To be consistent with the\r
+> other cases (where a deleted message is in a matched thread) we might\r
+> want to return the message with the not-matched flag set (eg in\r
+> JSON). But my patch doesn't, as it never even sees the thread since it\r
+> doesn't match.\r
+> \r
+> Looking at notmuch-show.c I think we should not apply the exclude tags\r
+> to do_show_single, but usually should apply it to do_show. One solution\r
+> which is simple and is at least close to right would be to get do_show\r
+> to return the number of threads found. If this is zero then retry the\r
+> query without the excludes (possible setting the match_flag to zero on\r
+> each message since we know it does not match)\r
+> \r
+> This is not a completely correct solution as if you ask notmuch-show to\r
+> show more than one thread it might  threads which only contain deleted\r
+> messages.\r
+> \r
+> I can't see other good possibilities without slowing down the normal\r
+> path a lot (eg find all threads that match the original query and then\r
+> apply the argument above).\r
+> \r
+> Any thoughts?\r
+\r
+Oh dear.\r
+\r
+Well, here's one idea.  Instead of doing a single thread query in\r
+show, do a thread query without the exclusions and then a message\r
+query with the exclusions.  Output all of the messages from the first\r
+query, but use the results of the second query to determine which\r
+messages are "matched".  The same could be accomplished in the library\r
+somewhat more efficiently, but it's not obvious to me what the API\r
+would be.\r
+\r
+> Incidentally, is there something strange at the end of notmuch-show.c: I\r
+> can't see how we could ever reach the last half dozen lines.\r
+\r
+Yes, I've wondered about that before, too.  I think none of those\r
+technically matter since they're all cleaning up resources that the OS\r
+is about to clean up for us.  It would be a problem if the database\r
+was open in write mode because Xapian's write lock hangs around for a\r
+split second after the process terminates if you don't close the\r
+database yourself, but in read mode it doesn't take any locks.  Not\r
+that this excuses the code.\r