Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 25 / bebdc2985ad4e5e4d9d1cbbf08589631a38036
1 Return-Path: <Sebastian@SSpaeth.de>\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 538D3431FD0\r
6         for <notmuch@notmuchmail.org>; Thu,  2 Jun 2011 07:20:21 -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: -0.09\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.09 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         RCVD_IN_DNSWL_NONE=-0.0001, T_MIME_NO_TEXT=0.01] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 33hTjFNPDyN2 for <notmuch@notmuchmail.org>;\r
17         Thu,  2 Jun 2011 07:20:20 -0700 (PDT)\r
18 Received: from homiemail-a75.g.dreamhost.com (caiajhbdccah.dreamhost.com\r
19         [208.97.132.207])\r
20         by olra.theworths.org (Postfix) with ESMTP id 6BC4F431FB6\r
21         for <notmuch@notmuchmail.org>; Thu,  2 Jun 2011 07:20:20 -0700 (PDT)\r
22 Received: from homiemail-a75.g.dreamhost.com (localhost [127.0.0.1])\r
23         by homiemail-a75.g.dreamhost.com (Postfix) with ESMTP id B5F575EC084;\r
24         Thu,  2 Jun 2011 07:20:19 -0700 (PDT)\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=SSpaeth.de; h=from:to:subject\r
26         :in-reply-to:references:date:message-id:mime-version:\r
27         content-type; q=dns; s=sspaeth.de; b=QU8B0jbQUKX+1bOQ9YDkRBUpjwi\r
28         WHtJo5sglyEoi9KZSTf1OxLaEDPi/U3cGPQkCNIMuXSBYr3B/gWmEaTQPi5L9S/8\r
29         yUzlAQ5cElWdHRxGsbiyqBDP2mBtKGIzSjEtrL1EzfCTNu1sWW9OQhwFDn9+yXbW\r
30         FHdESGzTtpIim1wo=\r
31 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=SSpaeth.de; h=from:to\r
32         :subject:in-reply-to:references:date:message-id:mime-version:\r
33         content-type; s=sspaeth.de; bh=1tMr6XP+VRw8lTz3LzUX3PuAc3I=; b=d\r
34         g3rp1RGWNYRHlRi2EshqlY6WZsdtbjCY414QrrJbwumriLPVs74ZT06fn/nVwEcB\r
35         jjWzYzAj+aFNnsEe+6hEOsKNjGeHLJeT3I8jgJ0dI2NTqtYb0XwEKgBHFKmX9KgM\r
36         v3vp2XGeUU4kJ+8Qb6XMolbpgfpFXxlYPDXpRry9uE=\r
37 Received: from spaetzbook.sspaeth.de (unknown [194.204.5.155])\r
38         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
39         (No client certificate requested)\r
40         (Authenticated sender: fax@sspaeth.de)\r
41         by homiemail-a75.g.dreamhost.com (Postfix) with ESMTPSA id EEF535EC07E; \r
42         Thu,  2 Jun 2011 07:20:17 -0700 (PDT)\r
43 Received: by spaetzbook.sspaeth.de (sSMTP sendmail emulation);\r
44         Thu, 02 Jun 2011 16:20:15 +0200\r
45 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
46 To: Brian May <brian@microcomaustralia.com.au>,\r
47         notmuch <notmuch@notmuchmail.org>\r
48 Subject: Re: [python] get all messages of a thread\r
49 In-Reply-To: <BANLkTi=df3+LBWasFic9ZNrKaLGA7Bmdew@mail.gmail.com>\r
50 References: <1306588052-sup-9838@brick>\r
51         <BANLkTikEJ9dJ5kLg2QJQ+egHg2sh7S1wiA@mail.gmail.com>\r
52         <87aae07lxi.fsf@SSpaeth.de>\r
53         <BANLkTi=df3+LBWasFic9ZNrKaLGA7Bmdew@mail.gmail.com>\r
54 User-Agent: Notmuch/0.5-209-gc8b5718 (http://notmuchmail.org) Emacs/23.2.1\r
55         (x86_64-pc-linux-gnu)\r
56 Date: Thu, 02 Jun 2011 16:20:14 +0200\r
57 Message-ID: <87r57cuxgh.fsf@SSpaeth.de>\r
58 MIME-Version: 1.0\r
59 Content-Type: multipart/signed; boundary="=-=-=";\r
60         micalg=pgp-sha1; protocol="application/pgp-signature"\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Thu, 02 Jun 2011 14:20:21 -0000\r
74 \r
75 --=-=-=\r
76 Content-Transfer-Encoding: quoted-printable\r
77 \r
78 On Thu, 2 Jun 2011 19:43:29 +1000, Brian May wrote:\r
79 > On 2 June 2011 17:05, Sebastian Spaeth <Sebastian@sspaeth.de> wrote:\r
80 >=20\r
81 > > What would be the best way to solve this (besides fixing the C api to\r
82 > > allow to reset the iterator ;-) ?)\r
83 \r
84 > * It is not easy to fix the C api to reset the iterator (what about\r
85 > repeating the search?)\r
86 \r
87 I am not sure about the difficulty of that, I am not a C-kind of\r
88 guy. Repeating the search would be easy but potentially gives you\r
89 different results since the db could have changed since then.\r
90 =20\r
91 > * The only accurate way to get the number of messages is to iterate throu=\r
92 gh\r
93 > every search result and count them?\r
94 \r
95 There is count_messages() which wraps notmuch_query_count_messages which\r
96 invokes some very quick xapian function. But the xapian docs explicitely\r
97 state that it's xapians best guess and not guaranteed to be the real\r
98 number of messages (although it always was in my attempts). And you\r
99 don't want len() to return an approximation of the iterator length....\r
100 \r
101 > If so, then len(...) I think might be very slow if there are a large numb=\r
102 er\r
103 > of elements.\r
104 =20\r
105 > Maybe it might be easier/better to implement object.__nonzero__(self)\r
106 >  instead of the object.__len__(self) method?\r
107 >=20\r
108 > http://docs.python.org/reference/datamodel.html\r
109 >=20\r
110 > object.__nonzero__(self)\r
111 > Called to implement truth value testing and the built-in operation bool();\r
112 > should return False or True, or their integer equivalents 0 or 1. When th=\r
113 is\r
114 > method is not defined, __len__() is called, if it is defined, and the obj=\r
115 ect\r
116 > is considered true if its result is nonzero. If a class defines neither\r
117 > __len__() nor __nonzero__(), all its instances are considered true.\r
118 \r
119 Interesting, did not know about this one. I guess that would solve the\r
120 example with the:\r
121 \r
122 t =3D query.search_threads()\r
123 \r
124 if t:\r
125   for thread in t:\r
126     print thread\r
127 \r
128 Actually the "if t:" is no longer needed, I just tried a query returning\r
129 no Threads and=20\r
130 \r
131 for thread in threads:\r
132   pass\r
133 \r
134 works just fine with an empty Threads() object.\r
135 \r
136 I made the change, and implemented __nonzero__ and removed the len()\r
137 method. It just doesn't make sense on 1-time iterators. (I documented\r
138 the change in the API docs). Sorry if this breaks existing code.\r
139 \r
140 list(Threads()) works just fine too, it just took a while to create a\r
141 list of 13k Thread() objects on this laptop. (and list() will of course\r
142 not return until it is finished).\r
143 \r
144 \r
145 Sebastian\r
146 \r
147 --=-=-=\r
148 Content-Type: application/pgp-signature\r
149 \r
150 -----BEGIN PGP SIGNATURE-----\r
151 Version: GnuPG v1.4.11 (GNU/Linux)\r
152 \r
153 iEYEARECAAYFAk3nnB4ACgkQVYX1jMgnoGIRMgCeOMJq2ej5K9/WXtxMLMjD02lo\r
154 HJoAn1BMBhRczltfWmOI/GQkquUv8WdB\r
155 =T4tg\r
156 -----END PGP SIGNATURE-----\r
157 --=-=-=--\r