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 1340F431FC0 for ; Mon, 23 Nov 2009 05:06:52 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 S3H9nSoDYBcm for ; Mon, 23 Nov 2009 05:06:51 -0800 (PST) Received: from mail-bw0-f224.google.com (mail-bw0-f224.google.com [209.85.218.224]) by olra.theworths.org (Postfix) with ESMTP id D1E8B431FBC for ; Mon, 23 Nov 2009 05:06:50 -0800 (PST) Received: by bwz24 with SMTP id 24so3879783bwz.30 for ; Mon, 23 Nov 2009 05:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject :in-reply-to:references:date:message-id:mime-version:content-type; bh=u8lee9onceZ5rvYjZmQlHL0pPhyF+LUQA25XwR83PjE=; b=BJtBoijWdQsn1Mq5z1ch6b3mOa6hysyyHRBv+usGq6hIqZ3vrs6lNIFt+VabMXDZOb ByPhMNOAUWQ+gemmUsBts6C08B9Z89qIPzMrk6u1j5QqhUFl6Ed/yFoPzPH4NjSawoLM mlrLW8Y2wVTMYavRGhevWic56HK4axfGd2tmw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version:content-type; b=OxWcPdPoZJFdfeRPOzbEtUC4ITlxQh6T0vN//WYF4SE2tWC7hiW1hhyGZVyeR6QemT ARlV1/ds1BKulpPQHW1V2qO5AFfR81/rhRzC0xIu06SUaMc2U+QKVxD0qYnJVUibnhrw mqz97x00C84dtV1IpsS7eMbspgzZA59FV8m0E= Received: by 10.204.148.78 with SMTP id o14mr4656564bkv.83.1258981609748; Mon, 23 Nov 2009 05:06:49 -0800 (PST) Received: from kunyang (vawpc43.ethz.ch [129.132.59.11]) by mx.google.com with ESMTPS id 9sm5690477fks.52.2009.11.23.05.06.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 23 Nov 2009 05:06:48 -0800 (PST) Sender: Jed Brown From: Jed Brown To: Carl Worth , notmuch@notmuchmail.org In-Reply-To: <87ocmtg9ni.fsf@yoom.home.cworth.org> References: <1258920736-14205-1-git-send-email-jed@59A2.org> <87ocmtg9ni.fsf@yoom.home.cworth.org> Date: Mon, 23 Nov 2009 14:07:20 +0100 Message-ID: <87y6lx4cfr.fsf@59A2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [notmuch] [PATCH] New function notmuch-search-operate-all: operate on all messages in the current query. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Mon, 23 Nov 2009 13:06:52 -0000 On Mon, 23 Nov 2009 05:14:25 +0100, Carl Worth wrote: > Second, I like that you just used the search string again, (as opposed > to just walking through the buffer looking at thread IDs). That seems > elegant. It was *easy*. > First, this creates a race condition in that the user will rightly > expect to only be adding/removing tags from the visible results. But if > new mail has been incorporated between creating the current view and > running '*' then threads could be tagged that were never seen and that > could be problematic. Agreed and I had also thought of the case you described. Note that Gmail does not solve the race condition. When in summary mode: * Marking a thread as read applies to all messages in the thread. The thread contents are being updated concurrently so you may mark threads you have already seen. * Same story with archiving (aka. remove inbox). * Starring a thread applies to the last message in the thread, this could be a newly arrived message that is not currently displayed. I think that handling a concurrent changes to the match results is a somewhat hard problem. You have to store the message ids of everything in the current query if you want to avoid the race. > Second, since we're in the search view which shows threads, we should > really be operating on threads. But this tag command won't work like the > '+' and '-' commands in this buffer. Those commands will add/remove a > tag to/from every message in the thread[*]. The new '*' command, however > will only be changing tags on messages that match the query. I'm not convinced that we want to operate on the entire thread. Applying the tag only to the matched messages is enough to find the thread, and it may really be desirable to only have it applied to certain messages in the thread. For example, I might have constructed an elaborate query to find five messages, including a couple that are burried in 100-message threads in which case I would definitely not want to tag entire threads. > So I think we should fix both of these issues by looping over each line > of the buffer and calling (notmuch-search-add-tag) or > (notmuch-search-remove-tag). Presumably you don't mean this literally because that would be horribly slow. What you want is to gather up all the message ids in all the threads with at least one message matching the current query (and currently displayed). I think this is only possible if notmuch-search holds message IDs for everything in the matched threads. If we are happy to just tag the matched messages instead of the entire thread, we would only store the message ids for the matched messages. > Oh, here's one: We could add something like "notmuch tag --expecting= > 1/23 " that would not do the tag unless the search string > matched 1 message out of 23 total messages in the thread. Then we could > give a warning to the user. I like this, but it still presents a minor race condition (suppose another client swaps the unread tag on two messages in the same thread). The only way to guarantee that you are operating on the displayed messages is to store their message ids. > That works for the single-thread case, but the warning would be harder > for the user to deal with in the '*' case. Or maybe not---the emacs > function could just stop on the first line with the error and then the > user would see what's going on. If you can implement notmuch tag --expecting with similar efficiency to the present, then I would vote for notifying the user and asking for confirmation if the number of matches has changed. This would be significantly safer than what Gmail does which ought to be sufficient for now given the age of notmuch. Jed