1 Return-Path: <stewart@flamingspork.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 BEEB8431FBD
\r
6 for <notmuch@notmuchmail.org>; Mon, 15 Feb 2010 18:21:33 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.007 tagged_above=-999 required=5 tests=[AWL=0.592,
\r
12 BAYES_00=-2.599] autolearn=ham
\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 E5OeefNZkxtk for <notmuch@notmuchmail.org>;
\r
16 Mon, 15 Feb 2010 18:21:32 -0800 (PST)
\r
17 Received: from kaylee.flamingspork.com (kaylee.flamingspork.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id 8F6AE431FBC
\r
20 for <notmuch@notmuchmail.org>; Mon, 15 Feb 2010 18:21:32 -0800 (PST)
\r
21 Received: from willster (localhost [127.0.0.1])
\r
22 by kaylee.flamingspork.com (Postfix) with ESMTPS id 6772E6393;
\r
23 Tue, 16 Feb 2010 02:18:31 +0000 (UTC)
\r
24 Received: from flamingspork.com (localhost.localdomain [127.0.0.1])
\r
25 by willster (Postfix) with ESMTPS id 3AD461026130;
\r
26 Tue, 16 Feb 2010 13:21:30 +1100 (EST)
\r
27 Date: Tue, 16 Feb 2010 13:21:28 +1100
\r
28 From: Stewart Smith <stewart@flamingspork.com>
\r
29 To: Tim Stoakes <notmuch@stoakes.net>, notmuch@notmuchmail.org
\r
30 Message-ID: <20100216022128.GH22402@flamingspork.com>
\r
31 References: <87d43b2oif.fsf@yoom.home.cworth.org>
\r
32 <9bfdedddeab9c58cd45d8d448323d0fc@localhost>
\r
33 <87skc23327.fsf@yoom.home.cworth.org>
\r
34 <4b0eef22.JwxdgTGElffx149F%michiel@michielbuddingh.net>
\r
35 <87ws1bjpmm.fsf@yoom.home.cworth.org> <878wdfkhcl.fsf@aegir.org.uk>
\r
36 <20100210031339.GH16686@mail.rocksoft.com>
\r
37 <20100215081331.GD22402@flamingspork.com>
\r
38 <20100216015856.GG22402@flamingspork.com>
\r
39 <20100216021250.GB21780@lapse.rw.madduck.net>
\r
41 Content-Type: multipart/signed; micalg=pgp-sha1;
\r
42 protocol="application/pgp-signature"; boundary="PEIAKu/WMn1b1Hv9"
\r
43 Content-Disposition: inline
\r
44 In-Reply-To: <20100216021250.GB21780@lapse.rw.madduck.net>
\r
45 User-Agent: Mutt/1.5.20 (2009-06-14)
\r
46 Subject: Re: [notmuch] [PATCH] notmuch: Respect maildir message flags
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\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: Tue, 16 Feb 2010 02:21:33 -0000
\r
63 Content-Type: text/plain; charset=us-ascii
\r
64 Content-Disposition: inline
\r
65 Content-Transfer-Encoding: quoted-printable
\r
67 On Tue, Feb 16, 2010 at 03:12:50PM +1300, martin f krafft wrote:
\r
68 > also sprach Stewart Smith <stewart@flamingspork.com> [2010.02.16.1458 +13=
\r
70 > > + case 'R': /* replied */
\r
71 > > + notmuch_message_add_tag (message, "answered");
\r
74 > 'r' means replied, not 'answered'.
\r
78 (i have to admit... i didn't look too closely at this... it just
\r
79 worked enough for me)
\r
82 > > + case 'T': /* trashed */
\r
83 > > + notmuch_message_add_tag (message, "deleted");
\r
86 > Same. trashed and deleted are not the same thing.
\r
88 changed to 'trashed'.
\r
90 > I don't want to get into an argument over this, because I think this
\r
91 > already exposes a problem: you are putting into global namespace
\r
92 > something not everyone might want, or agree with.
\r
94 > Why not use 'maildirflags::replied' instead? People can always map
\r
95 > that to something in the global namespace.
\r
97 What about putting them all in there except for the seen tag, with the
\r
98 seen tag dictating if it gets marked 'unread' or not? I cannot imagine
\r
99 where somebody would want this not to be the case... it was bad enough
\r
100 discovering 100,000 unread messages :)
\r
102 What about this patch (just with those few things fixed)?
\r
104 diff --git a/notmuch-new.c b/notmuch-new.c
\r
105 index f25c71f..8303047 100644
\r
106 --- a/notmuch-new.c
\r
107 +++ b/notmuch-new.c
\r
108 @@ -39,6 +39,7 @@ typedef struct {
\r
110 int processed_files;
\r
111 int added_messages;
\r
113 struct timeval tv_start;
\r
115 _filename_list_t *removed_files;
\r
116 @@ -169,6 +170,60 @@ _entries_resemble_maildir (struct dirent **entries, in=
\r
121 +/* Tag new mail according to its Maildir attribute flags.
\r
123 + * Test if the mail file's filename contains any of the
\r
124 + * standard Maildir attributes, and translate these to
\r
125 + * the corresponding standard notmuch tags.
\r
127 + * If the message is not marked as 'seen', or if no
\r
128 + * flags are present, tag as 'inbox, unread'.
\r
131 +derive_tags_from_maildir_flags (notmuch_message_t *message,
\r
132 + const char * path)
\r
134 + int seen =3D FALSE;
\r
135 + int end_of_flags =3D FALSE;
\r
136 + size_t l =3D strlen(path);
\r
138 + /* Non-experimental message flags start with this */
\r
139 + char * i =3D strstr(path, ":2,");
\r
140 + i =3D (i) ? i : strstr(path, "!2,"); /* This format is used on VFAT */
\r
141 + if (i !=3D NULL) {
\r
143 + for (; i < (path + l) && !end_of_flags; i++) {
\r
146 + notmuch_message_add_tag (message, "maildir::flagged");
\r
148 + case 'R': /* replied */
\r
149 + notmuch_message_add_tag (message, "maildir::replied");
\r
152 + notmuch_message_add_tag (message, "maildir::draft");
\r
154 + case 'S': /* seen */
\r
157 + case 'T': /* trashed */
\r
158 + notmuch_message_add_tag (message, "maildir::trashed");
\r
160 + case 'P': /* passed */
\r
161 + notmuch_message_add_tag (message, "maildir::forwarded");
\r
164 + end_of_flags =3D TRUE;
\r
170 + if (i =3D=3D NULL || !seen) {
\r
171 + tag_inbox_and_unread (message);
\r
175 /* Examine 'path' recursively as follows:
\r
177 * o Ask the filesystem for the mtime of 'path' (fs_mtime)
\r
178 @@ -222,6 +277,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
179 notmuch_filenames_t *db_subdirs =3D NULL;
\r
181 notmuch_bool_t is_maildir, new_directory;
\r
182 + int maildir_detected =3D -1;
\r
184 if (stat (path, &st)) {
\r
185 fprintf (stderr, "Error reading directory %s: %s\n",
\r
186 @@ -301,6 +357,28 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
190 + /* If this directory is a Maildir folder, we need to
\r
191 + * ignore any subdirectories marked tmp/, and scan for
\r
192 + * Maildir attributes on messages contained in the sub-
\r
193 + * directories 'new' and 'cur'. */
\r
194 + if (maildir_detected !=3D 0 &&
\r
195 + (entry->d_type =3D=3D DT_DIR || entry->d_type =3D=3D DT_UNKNOWN) &&
\r
196 + ((strcmp (entry->d_name, "tmp") =3D=3D 0) ||
\r
197 + (strcmp (entry->d_name, "new") =3D=3D 0) ||
\r
198 + (strcmp (entry->d_name, "cur") =3D=3D 0))) {
\r
200 + if (maildir_detected =3D=3D -1) {
\r
201 + maildir_detected =3D _entries_resemble_maildir(fs_entries, num_fs_en=
\r
204 + if (maildir_detected =3D=3D 1) {
\r
205 + if (strcmp (entry->d_name, "tmp") =3D=3D 0) {
\r
208 + state->tag_maildir =3D TRUE;
\r
213 next =3D talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
214 status =3D add_files_recursive (notmuch, next, state);
\r
215 if (status && ret =3D=3D NOTMUCH_STATUS_SUCCESS)
\r
216 @@ -412,7 +490,12 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
218 case NOTMUCH_STATUS_SUCCESS:
\r
219 state->added_messages++;
\r
220 - tag_inbox_and_unread (message);
\r
221 + if (state->tag_maildir) {
\r
222 + derive_tags_from_maildir_flags (message,
\r
225 + tag_inbox_and_unread (message);
\r
228 /* Non-fatal issues (go on to next file) */
\r
229 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
235 Content-Type: application/pgp-signature; name="signature.asc"
\r
236 Content-Description: Digital signature
\r
237 Content-Disposition: inline
\r
239 -----BEGIN PGP SIGNATURE-----
\r
240 Version: GnuPG v1.4.9 (GNU/Linux)
\r
242 iEYEARECAAYFAkt6AScACgkQFtJC9tN9Son7nQCglX2I9IQTe2cdzUb/3qNGWyE2
\r
243 Y+kAoKttgVm/E3wdbjFNMgrjwYLBCVM0
\r
245 -----END PGP SIGNATURE-----
\r
247 --PEIAKu/WMn1b1Hv9--
\r