Re: [python] get all messages of a thread
[notmuch-archives.git] / ce / 87cf815cac42380092dac9899c01bdf8a48bbd
1 Return-Path: <prvs=0512aedc7=jrosenthal@jhu.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 3A6B6431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 18 Mar 2011 00:32:04 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 5M6UMjWBE6bx for <notmuch@notmuchmail.org>;\r
16         Fri, 18 Mar 2011 00:32:03 -0700 (PDT)\r
17 Received: from ipex1.johnshopkins.edu (ipex1.johnshopkins.edu [162.129.8.141])\r
18         (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 9DB16431FB5\r
21         for <notmuch@notmuchmail.org>; Fri, 18 Mar 2011 00:32:03 -0700 (PDT)\r
22 X-IronPort-AV: E=Sophos;i="4.63,204,1299474000"; d="scan'208";a="54721673"\r
23 Received: from c-69-255-36-229.hsd1.md.comcast.net (HELO lucky.home)\r
24         ([69.255.36.229])\r
25         by ipex1.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
26         18 Mar 2011 03:32:00 -0400\r
27 Received: from jkr by lucky.home with local (Exim 4.72)\r
28         (envelope-from <jrosenthal@jhu.edu>)\r
29         id 1Q0UAB-000338-L6; Fri, 18 Mar 2011 03:31:59 -0400\r
30 From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
31 To: Ben Gamari <bgamari.foss@gmail.com>, notmuch <notmuch@notmuchmail.org>\r
32 Subject: Re: My mail configuration\r
33 In-Reply-To: <87tyfu3k5a.fsf@gmail.com>\r
34 References: <87tyfu3k5a.fsf@gmail.com>\r
35 User-Agent: Notmuch/0.5-81-g708c4f4 (http://notmuchmail.org) Emacs/23.2.1\r
36         (i486-pc-linux-gnu)\r
37 Date: Fri, 18 Mar 2011 03:31:59 -0400\r
38 Message-ID: <877hbwevf4.fsf@lucky.home>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain; charset=us-ascii\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Fri, 18 Mar 2011 07:32:04 -0000\r
54 \r
55 Hi Ben,\r
56 \r
57 On Wed, 23 Feb 2011 09:22:57 -0500, Ben Gamari <bgamari.foss@gmail.com> wrote:\r
58 > Here is my mail sorting script that has been slowly evolving for almost\r
59 > a year now. \r
60 \r
61 Thanks for posting this, and sorry for digging this up so much later. I\r
62 was thinking of setting up something similar, and had one question:\r
63 \r
64 > # Freeze new messages\r
65 > q_new = notmuch.Query(db, 'tag:new')\r
66 > n_msgs = 0\r
67 > for msg in q_new.search_messages():\r
68 >         msg.freeze()\r
69 >         n_msgs += 1\r
70 \r
71 It seems like every time you iterate over `q_new.search_messages()', you\r
72 run a new search on tag:new. So at the end, when you thaw the messages,\r
73 you're running that search again, from scratch:\r
74 \r
75 > # Tag remaining new items for inbox\r
76 > tag_search(db, 'tag:new', '+inbox', '-new')\r
77\r
78 > # Thaw new messages\r
79 > for msg in q_new.search_messages():\r
80 >         msg.thaw()\r
81 \r
82 But there are no longer and "tag:new"s, so there shouldn't be any\r
83 results for `q_new.search_messages()', should there? It seems like\r
84 it's thawing 0 messages. Playing around with it, it doesn't seem to make\r
85 a difference, so perhaps thawing is unneccessary if you're exiting after\r
86 tagging. Or am I misunderstanding something?\r
87 \r
88 By the way, my understanding of the bindings is that you can avoid\r
89 running the new searches by dumping a Messages object into a list. So,\r
90 you can do something like:\r
91 \r
92     new_msg_obj = q_new.search_messages()\r
93     new_msg_list = [m for m in new_msg_obj]\r
94 \r
95 and then deal with the list from there on out. Not sure if that would\r
96 buy you much performance over running the query repeatedly, but it\r
97 couldn't hurt, and it would seem closer to the effect that you're aiming\r
98 at (since the members of the list would be set from the first query, and\r
99 therefore you'd be thawing the same elements you froze in the first\r
100 place).\r
101 \r
102 Thanks again for posting this.\r
103 \r
104 Best,\r
105 Jesse\r