My mail configuration
Jesse Rosenthal
jrosenthal at jhu.edu
Fri Mar 18 00:31:59 PDT 2011
Hi Ben,
On Wed, 23 Feb 2011 09:22:57 -0500, Ben Gamari <bgamari.foss at gmail.com> wrote:
> Here is my mail sorting script that has been slowly evolving for almost
> a year now.
Thanks for posting this, and sorry for digging this up so much later. I
was thinking of setting up something similar, and had one question:
> # Freeze new messages
> q_new = notmuch.Query(db, 'tag:new')
> n_msgs = 0
> for msg in q_new.search_messages():
> msg.freeze()
> n_msgs += 1
It seems like every time you iterate over `q_new.search_messages()', you
run a new search on tag:new. So at the end, when you thaw the messages,
you're running that search again, from scratch:
> # Tag remaining new items for inbox
> tag_search(db, 'tag:new', '+inbox', '-new')
>
> # Thaw new messages
> for msg in q_new.search_messages():
> msg.thaw()
But there are no longer and "tag:new"s, so there shouldn't be any
results for `q_new.search_messages()', should there? It seems like
it's thawing 0 messages. Playing around with it, it doesn't seem to make
a difference, so perhaps thawing is unneccessary if you're exiting after
tagging. Or am I misunderstanding something?
By the way, my understanding of the bindings is that you can avoid
running the new searches by dumping a Messages object into a list. So,
you can do something like:
new_msg_obj = q_new.search_messages()
new_msg_list = [m for m in new_msg_obj]
and then deal with the list from there on out. Not sure if that would
buy you much performance over running the query repeatedly, but it
couldn't hurt, and it would seem closer to the effect that you're aiming
at (since the members of the list would be set from the first query, and
therefore you'd be thawing the same elements you froze in the first
place).
Thanks again for posting this.
Best,
Jesse
More information about the notmuch
mailing list