Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 0e / d742bc1ca88a22a3042dd095a112619120e32c
1 Return-Path: <doctormo@gmail.com>\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 8890C431FD0\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Sep 2011 18:34:39 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 TT4P7oUPK3CL for <notmuch@notmuchmail.org>;\r
17         Wed,  7 Sep 2011 18:34:38 -0700 (PDT)\r
18 Received: from mail-qw0-f41.google.com (mail-qw0-f41.google.com\r
19         [209.85.216.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 77C7A431FB6\r
22         for <notmuch@notmuchmail.org>; Wed,  7 Sep 2011 18:34:38 -0700 (PDT)\r
23 Received: by qwa26 with SMTP id 26so234852qwa.28\r
24         for <notmuch@notmuchmail.org>; Wed, 07 Sep 2011 18:34:36 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=subject:from:to:cc:content-type:date:message-id:mime-version\r
27         :x-mailer; bh=4ayS/J3O86g7aEykmELa/D+9gYJoKMLSar97FHUthLw=;\r
28         b=C5QfcfY/Vz5WQOxtrwgAvFXhn22FxPMmFEE8DFbfZLzQiOw6UI9Mx//PuH/dlxRTh+\r
29         ZwI7/SvtF6rJaJPqnuH0Rz4jNyce1GB9+rr8O1dvGO1FypTcgkh6Fw7l1Q5w+D48mrTu\r
30         VW79mu+yljQOC7Rg5w/LTM59RoVKpkfMVcWBg=\r
31 Received: by 10.224.215.130 with SMTP id he2mr75841qab.0.1315445676769;\r
32         Wed, 07 Sep 2011 18:34:36 -0700 (PDT)\r
33 Received: from [192.168.1.190] (pool-68-163-190-45.bos.east.verizon.net.\r
34         [68.163.190.45])\r
35         by mx.google.com with ESMTPS id dx7sm1644073qab.11.2011.09.07.18.34.34\r
36         (version=SSLv3 cipher=OTHER); Wed, 07 Sep 2011 18:34:35 -0700 (PDT)\r
37 Subject: Patch: Flush and Reopen\r
38 From: Martin Owens <doctormo@gmail.com>\r
39 To: Notmuch developer list <notmuch@notmuchmail.org>\r
40 Content-Type: multipart/mixed; boundary="=-QH9fXRHOIjOq1XQ/OK0q"\r
41 Date: Wed, 07 Sep 2011 21:34:34 -0400\r
42 Message-ID: <1315445674.32058.183.camel@delen>\r
43 Mime-Version: 1.0\r
44 X-Mailer: Evolution 2.30.3 \r
45 X-Mailman-Approved-At: Thu, 08 Sep 2011 14:21:55 -0700\r
46 Cc: Paul Tagliamonte <paultag@ubuntu.com>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Thu, 08 Sep 2011 01:34:39 -0000\r
60 \r
61 \r
62 --=-QH9fXRHOIjOq1XQ/OK0q\r
63 Content-Type: text/plain; charset="UTF-8"\r
64 Content-Transfer-Encoding: 7bit\r
65 \r
66 Hello,\r
67 \r
68 Per discussions on irc, I've attached a patch for your consideration\r
69 which allows the developer to run two new database commands;\r
70 \r
71 notmuch_database_flush - used on read_write databases to commit changes\r
72 to disk\r
73 notmuch_database_reopen - used on read_only databases to reload from the\r
74 disk\r
75 \r
76 Used in conjunction they can allow access by multiple programs at the\r
77 same time. There are also changes to the python bindings to add these\r
78 two methods to the database class.\r
79 \r
80 Regards, Martin Owens\r
81 \r
82 --=-QH9fXRHOIjOq1XQ/OK0q\r
83 Content-Disposition: attachment;\r
84  filename*0=0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.pat;\r
85  filename*1=ch\r
86 Content-Type: text/x-patch;\r
87  name="0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.patch";\r
88  charset="UTF-8"\r
89 Content-Transfer-Encoding: 7bit\r
90 \r
91 >From 92b89aad3101faa42c6fdca9b6683ebfa42ab3b0 Mon Sep 17 00:00:00 2001\r
92 From: Martin Owens <doctormo@gmail.com>\r
93 Date: Wed, 7 Sep 2011 21:15:54 -0400\r
94 Subject: [PATCH] Add flush and reopen methods to the libnotmuch and to the python bindings. Flush allows read_write databases to commit their changes, forcing a flush to disk and reopen allows a read_only database to reread from the disk.\r
95 \r
96 Also added a handler for Xapian DatabaseChangedError which occurs when the flush happens to read only databases.\r
97 ---\r
98  bindings/python/notmuch/database.py |   10 ++++++++++\r
99  debian/changelog                    |    6 +++++-\r
100  debian/control                      |    2 +-\r
101  debian/libnotmuch1.symbols          |    2 ++\r
102  lib/database.cc                     |   33 ++++++++++++++++++++++++++-------\r
103  lib/notmuch.h                       |    8 ++++++++\r
104  lib/query.cc                        |   10 +++++++---\r
105  7 files changed, 59 insertions(+), 12 deletions(-)\r
106 \r
107 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
108 index f18ca14..b6c1c31 100644\r
109 --- a/bindings/python/notmuch/database.py\r
110 +++ b/bindings/python/notmuch/database.py\r
111 @@ -432,6 +432,16 @@ class Database(object):\r
112  \r
113          return Query(self, querystring)\r
114  \r
115 +    def reopen(self):\r
116 +        """Reopens a read only database, when the data has changed, this is required."""\r
117 +        if self._db is not None:\r
118 +            nmlib.notmuch_database_reopen(self._db)\r
119 +\r
120 +    def flush(self):\r
121 +        """Flushes the search database, only available when in read-write."""\r
122 +        if self._db is not None:\r
123 +            nmlib.notmuch_database_flush(self._db)\r
124 +\r
125      def __repr__(self):\r
126          return "'Notmuch DB " + self.get_path() + "'"\r
127  \r
128 diff --git a/debian/changelog b/debian/changelog\r
129 index c2b7552..565edfb 100644\r
130 --- a/debian/changelog\r
131 +++ b/debian/changelog\r
132 @@ -1,8 +1,12 @@\r
133  notmuch (0.8~rc1-1) experimental; urgency=low\r
134  \r
135 +  [ David Bremner ]\r
136    * Upstream release candidate.\r
137  \r
138 - -- David Bremner <bremner@debian.org>  Tue, 06 Sep 2011 22:24:24 -0300\r
139 +  [ Martin Owens (DoctorMO) ]\r
140 +  * Re-new-world-order\r
141 +\r
142 + -- Martin Owens (DoctorMO) <doctormo@gmail.com>  Wed, 07 Sep 2011 18:19:50 -0400\r
143  \r
144  notmuch (0.7-1) unstable; urgency=low\r
145  \r
146 diff --git a/debian/control b/debian/control\r
147 index 03afdf4..a72fe1b 100644\r
148 --- a/debian/control\r
149 +++ b/debian/control\r
150 @@ -5,7 +5,7 @@ Maintainer: Carl Worth <cworth@debian.org>\r
151  Uploaders: Jameson Graef Rollins <jrollins@finestructure.net>, martin f. krafft <madduck@debian.org>, \r
152            David Bremner <bremner@debian.org>\r
153  Build-Depends: debhelper (>= 7.0.50~), pkg-config, libxapian-dev, \r
154 - libgmime-2.4-dev, libtalloc-dev, libz-dev,  python-all (>= 2.6.6-3~),\r
155 + libgmime-2.4-dev, libtalloc-dev, libz-dev,  python-all (>= 2.6.6),\r
156   emacs23-nox | emacs23 (>=23~) | emacs23-lucid (>=23~)\r
157  Standards-Version: 3.9.2\r
158  Homepage: http://notmuchmail.org/\r
159 diff --git a/debian/libnotmuch1.symbols b/debian/libnotmuch1.symbols\r
160 index 05d86e6..7e42b0e 100644\r
161 --- a/debian/libnotmuch1.symbols\r
162 +++ b/debian/libnotmuch1.symbols\r
163 @@ -3,6 +3,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
164   notmuch_database_close@Base 0.3\r
165   notmuch_database_create@Base 0.3\r
166   notmuch_database_find_message@Base 0.3\r
167 + notmuch_database_flush@Base 0.3\r
168   notmuch_database_get_all_tags@Base 0.3\r
169   notmuch_database_get_directory@Base 0.3\r
170   notmuch_database_get_path@Base 0.3\r
171 @@ -10,6 +11,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
172   notmuch_database_needs_upgrade@Base 0.3\r
173   notmuch_database_open@Base 0.3\r
174   notmuch_database_remove_message@Base 0.3\r
175 + notmuch_database_reopen@Base 0.3\r
176   notmuch_database_upgrade@Base 0.3\r
177   notmuch_directory_destroy@Base 0.3\r
178   notmuch_directory_get_child_directories@Base 0.3\r
179 diff --git a/lib/database.cc b/lib/database.cc\r
180 index 9c2f4ec..58b6c75 100644\r
181 --- a/lib/database.cc\r
182 +++ b/lib/database.cc\r
183 @@ -700,18 +700,37 @@ notmuch_database_open (const char *path,\r
184  }\r
185  \r
186  void\r
187 -notmuch_database_close (notmuch_database_t *notmuch)\r
188 +notmuch_database_reopen (notmuch_database_t *notmuch)\r
189  {\r
190      try {\r
191 -       if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
192 -           (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
193 +        if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)\r
194 +            (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->reopen();\r
195      } catch (const Xapian::Error &error) {\r
196 -       if (! notmuch->exception_reported) {\r
197 -           fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
198 -                    error.get_msg().c_str());\r
199 -       }\r
200 +        if (! notmuch->exception_reported) {\r
201 +            fprintf (stderr, "Error: A Xapian exception occurred reopening database: %s\n",\r
202 +                error.get_msg().c_str());\r
203 +        }\r
204      }\r
205 +}\r
206  \r
207 +void\r
208 +notmuch_database_flush (notmuch_database_t *notmuch)\r
209 +{\r
210 +    try {\r
211 +        if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
212 +            (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush();\r
213 +    } catch (const Xapian::Error &error) {\r
214 +        if (! notmuch->exception_reported) {\r
215 +            fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
216 +                error.get_msg().c_str());\r
217 +        }\r
218 +    }\r
219 +}\r
220 +\r
221 +void\r
222 +notmuch_database_close (notmuch_database_t *notmuch)\r
223 +{\r
224 +    notmuch_database_flush (notmuch);\r
225      delete notmuch->term_gen;\r
226      delete notmuch->query_parser;\r
227      delete notmuch->xapian_db;\r
228 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
229 index 974be8d..ca87b89 100644\r
230 --- a/lib/notmuch.h\r
231 +++ b/lib/notmuch.h\r
232 @@ -171,6 +171,14 @@ notmuch_database_t *\r
233  notmuch_database_open (const char *path,\r
234                        notmuch_database_mode_t mode);\r
235  \r
236 +/* Reopen a read_only database when the data source has changed */\r
237 +void\r
238 +notmuch_database_reopen (notmuch_database_t *database);\r
239 +\r
240 +/* Force a flush of the xapian database, also done on close */\r
241 +void\r
242 +notmuch_database_flush (notmuch_database_t *database);\r
243 +\r
244  /* Close the given notmuch database, freeing all associated\r
245   * resources. See notmuch_database_open. */\r
246  void\r
247 diff --git a/lib/query.cc b/lib/query.cc\r
248 index 6f02b04..d116367 100644\r
249 --- a/lib/query.cc\r
250 +++ b/lib/query.cc\r
251 @@ -185,10 +185,14 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
252         messages->iterator_end = mset.end ();\r
253  \r
254         return &messages->base;\r
255 -\r
256 +    } catch (const Xapian::DatabaseModifiedError &error) {\r
257 +      fprintf (stderr, "Database changed, you need to reopen it before performing queries.\n");\r
258 +      notmuch->exception_reported = TRUE;\r
259 +      talloc_free (messages);\r
260 +      return NULL;\r
261      } catch (const Xapian::Error &error) {\r
262 -       fprintf (stderr, "A Xapian exception occurred performing query: %s\n",\r
263 -                error.get_msg().c_str());\r
264 +       fprintf (stderr, "A Xapian exception occurred performing query: %s '%s'\n",\r
265 +                error.get_msg().c_str(), error.get_type());\r
266         fprintf (stderr, "Query string was: %s\n", query->query_string);\r
267         notmuch->exception_reported = TRUE;\r
268         talloc_free (messages);\r
269 -- \r
270 1.7.1\r
271 \r
272 \r
273 --=-QH9fXRHOIjOq1XQ/OK0q--\r
274 \r