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 1EA24429E20 for ; Fri, 11 Mar 2011 06:56:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.099 X-Spam-Level: X-Spam-Status: No, score=-0.099 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] 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 XjaoytiQKOfj for ; Fri, 11 Mar 2011 06:56:40 -0800 (PST) Received: from mail-vx0-f181.google.com (mail-vx0-f181.google.com [209.85.220.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 28C4A431FB5 for ; Fri, 11 Mar 2011 06:56:40 -0800 (PST) Received: by vxb39 with SMTP id 39so2701671vxb.26 for ; Fri, 11 Mar 2011 06:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=TOViimB8BR70eTnd4hpGJ6B1knXVdPry07KKg7s/Svw=; b=Ml3zjbo+kwKh6pOAuLy92VCIRZWECdVsnBatEar5X2b9JTaCp9T0MyrHwrAR+QE9sg FLUMmDtdzDRf6cM6BrKUE0iUrnMRl1NF+y/1RTw2b5/13ytBe1IDZ5XfptUwKqohD+nc ZmTQtxRqySI0v8gRHlKJ8ALjGd5Z3GwmIFFzc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; b=gbLQ3445oTFu05SlqS6bX+fWX4qGT13y43K9AVk/+lU4Y4EP24GiCyqzt8GmbEtxuA LHbJ0RC9mrsIiN+O9JjbHY59rP1Czcrd7Z5+BW4U3l2E1pAW4PkRpwvx7R+TGfvljzS3 Ik+WOUaJ2P5ZOJ+O4qRmquk8nhCamb2zxIOJY= Received: by 10.52.175.104 with SMTP id bz8mr3218507vdc.143.1299855397843; Fri, 11 Mar 2011 06:56:37 -0800 (PST) Received: from localhost (pool-72-79-214-225.spfdma.east.verizon.net [72.79.214.225]) by mx.google.com with ESMTPS id r20sm1572824vcf.34.2011.03.11.06.56.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Mar 2011 06:56:34 -0800 (PST) From: Ben Gamari To: Michal Sojka , notmuch Subject: Re: My mail configuration In-Reply-To: <87oc5o0w8a.fsf@resox.2x.cz> References: <87tyfu3k5a.fsf@gmail.com> <87oc5o0w8a.fsf@resox.2x.cz> User-Agent: Notmuch/0.5-64-gdd23272 (http://notmuchmail.org) Emacs/23.1.1 (x86_64-pc-linux-gnu) Date: Fri, 11 Mar 2011 09:55:37 -0500 Message-ID: <877hc5yady.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Fri, 11 Mar 2011 14:56:41 -0000 On Sun, 06 Mar 2011 22:34:13 +0100, Michal Sojka wrote: > Hi Ben, > > thanks for sharing your setup. > No worries. > It seems really interesting and probably > useful for many people. I'd propose to put it to wiki at > http://notmuchmail.org/initial_tagging/. > Done. > When compared to shell scripts for initial tagging, this seems to be > much faster because of freezing all new messages and thawing them after > all tagging is done. > Indeed, IMHO the python bindings are perfect for this sort of application. > Also the handling of watch and unseen tag is interesting. > The watch tag is one of the defining points of my workflow. I deal with a lot of lists although generally I'm interested in very few threads from each. The watch tag makes it very easy to find and follow relevant discussions. Just to make sure everyone understands what is happening here, the workflow works as follows, 1) When a message starting a new thread is encountered it is marked as "unseen" 2) I look at the "unseen" tag, marking threads of interest with "watch" 3) When a message comes in associated with an existing thread marked with "watch" it is marked with "inbox", otherwise it is ignored In other words, the "unseen" tag is an indicator of whether I have evaluated the message for interest. I use the standard "unread" tag to mark whether I have read the contents of the message. > The only thing I missed in your email is the definition of tag_search(). > You probably define it in notmuch_utils similarly to this: > Doh, thanks for pointing that out. Your tag_search implementation matches mine almost verbatim. For the record I have included notmuch_utils.py below. > Here I would suggest to add parentheses around %s like: > > tag_search(db, '( %s ) and tag:new' % filter, *tags) > > I use the 'or' operator in a few of my filters and without the > parentheses the query would be interpreted incorrectly. > Good point. Thanks! - Ben --8<---------------cut here---------------start------------->8--- import notmuch import logging def tag_message(msg, *tags): msg.freeze() for tag in tags: if tag[0] == '+': msg.add_tag(tag[1:]) elif tag[0] == '-': msg.remove_tag(tag[1:]) else: msg.add_tag(tag) msg.thaw() def tag_search(db, search, *tags): q = notmuch.Query(db, search) count = 0 for msg in q.search_messages(): count += 1 tag_message(msg, *tags) if count > 0: logging.debug('Tagging %d messages with (%s)' % (count, ' '.join(tags))) --8<---------------cut here---------------end--------------->8---