Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3FAE0429E54 for ; Sun, 22 Jan 2012 10:16:38 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l3VPXYUVhNUk for ; Sun, 22 Jan 2012 10:16:37 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id 8A172429E40 for ; Sun, 22 Jan 2012 10:16:37 -0800 (PST) X-AuditID: 12074424-b7fae6d000000906-5b-4f1c52853db4 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 85.BE.02310.5825C1F4; Sun, 22 Jan 2012 13:16:37 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0MIGamq024435; Sun, 22 Jan 2012 13:16:37 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0MIGZN9002555 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 22 Jan 2012 13:16:36 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rp1xZ-0001m7-7a; Sun, 22 Jan 2012 13:16:09 -0500 Date: Sun, 22 Jan 2012 13:16:09 -0500 From: Austin Clements To: Mark Walters Subject: Re: [PATCH] Automatically exclude tags in notmuch-show Message-ID: <20120122181609.GQ16740@mit.edu> References: <874nvric7c.fsf@qmul.ac.uk> <1327010583-23954-1-git-send-email-markwalters1009@gmail.com> <20120119225910.GT16740@mit.edu> <871uqvgrnm.fsf@qmul.ac.uk> <20120120171801.GA16740@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120120171801.GA16740@mit.edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT120NkvE3+L+Wz2L1XB6L6zdnMjsw eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGZ9XXmcuWCNasWShZAPja4EuRk4OCQETiS/3 pzFB2GISF+6tZ+ti5OIQEtjHKHHi+gooZwOjxOYLbxhBqoQETjJJvO+Lg0gsYZT4/aGRGSTB IqAq0fN8LpjNJqAhsW3/crAGEQEdiduHFrCD2MwC0hLffjeDrRMWsJeYvHQxWD0vSM27HVDb TjNKXJrwih0iIShxcuYTFohmLYkb/14CNXOADVr+jwMkzCmgK9H+4hNYuaiAisSUk9vYJjAK zULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0zfVyM0v0UlNKNzGCg9pFZQdj 8yGlQ4wCHIxKPLwvE6X9hVgTy4orcw8xSnIwKYnynvaQ8RfiS8pPqcxILM6ILyrNSS0+xCjB wawkwuv8GaicNyWxsiq1KB8mJc3BoiTOq6H1zk9IID2xJDU7NbUgtQgmK8PBoSTB+zoQaKhg UWp6akVaZk4JQpqJgxNkOA/Q8BsgNbzFBYm5xZnpEPlTjIpS4rzXQRICIImM0jy4XljSecUo DvSKMO9XkCoeYMKC634FNJgJaDBHnhTI4JJEhJRUAyMDt7VOvYHKw5uato6x7oUhvz/aTLhy +dOO3V8Pt5xon2TN0NAdJvZh01al2kImtdgXn/juy+WZXTh8rczSonuSS4T+D2dx46uHn6qt P/m5KvfVd7Gk8MfZt8sW262VcAlc09FWuF1q0rnYplc9pwXuTq1XClmbsXPa809mvA+DudTW tdiFr1NiKc5INNRiLipOBAASQJj5FQMAAA== Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2012 18:16:38 -0000 Quoth myself on Jan 20 at 12:18 pm: > Quoth Mark Walters on Jan 20 at 12:10 am: > > > > Ok Having said this is trivial I have found a problem. What should > > notmuch do if you do something like > > > > notmuch show id: > > and that message is marked with a deleted tag? To be consistent with the > > other cases (where a deleted message is in a matched thread) we might > > want to return the message with the not-matched flag set (eg in > > JSON). But my patch doesn't, as it never even sees the thread since it > > doesn't match. > > > > Looking at notmuch-show.c I think we should not apply the exclude tags > > to do_show_single, but usually should apply it to do_show. One solution > > which is simple and is at least close to right would be to get do_show > > to return the number of threads found. If this is zero then retry the > > query without the excludes (possible setting the match_flag to zero on > > each message since we know it does not match) > > > > This is not a completely correct solution as if you ask notmuch-show to > > show more than one thread it might threads which only contain deleted > > messages. > > > > I can't see other good possibilities without slowing down the normal > > path a lot (eg find all threads that match the original query and then > > apply the argument above). > > > > Any thoughts? > > Oh dear. > > Well, here's one idea. Instead of doing a single thread query in > show, do a thread query without the exclusions and then a message > query with the exclusions. Output all of the messages from the first > query, but use the results of the second query to determine which > messages are "matched". The same could be accomplished in the library > somewhat more efficiently, but it's not obvious to me what the API > would be. Here's a slightly crazier idea that's more library-invasive than the original approach, but probably better in the long run. Have notmuch_query_search_* return everything and make exclusion a message flag like NOTMUCH_MESSAGE_FLAG_MATCH. Tweak the definition of "matched" to mean "matched and not excluded" (specifically, a message would have the match flag or the excluded flag or neither, but not both). Search would skip threads with zero matched messages and I think show would Just Work. I can think of two ways to implement this. notmuch_query_search_* could perform both the original query and the query with exclusions and use the docid set from the second to compute the "excluded" message flag. Alternatively, it could examine the tags of each message directly to compute the flag. The latter is probably easier to implement, but probably slower. Thoughts?