unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ben Gamari <bgamari.foss@gmail.com>
To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch <notmuch@notmuchmail.org>
Subject: Re: My mail configuration
Date: Fri, 11 Mar 2011 09:55:37 -0500	[thread overview]
Message-ID: <877hc5yady.fsf@gmail.com> (raw)
In-Reply-To: <87oc5o0w8a.fsf@resox.2x.cz>

On Sun, 06 Mar 2011 22:34:13 +0100, Michal Sojka <sojkam1@fel.cvut.cz> 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---

  reply	other threads:[~2011-03-11 14:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 14:22 My mail configuration Ben Gamari
2011-03-06 21:34 ` Michal Sojka
2011-03-11 14:55   ` Ben Gamari [this message]
2011-03-18  7:31 ` Jesse Rosenthal
2011-03-18 12:32   ` Ben Gamari
2011-05-20 22:39 ` eric casteleijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877hc5yady.fsf@gmail.com \
    --to=bgamari.foss@gmail.com \
    --cc=notmuch@notmuchmail.org \
    --cc=sojkam1@fel.cvut.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).