Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / e7 / 031aa159548bb1697959cf9640509fd484d038
1 Return-Path: <ma.skies@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 DC6D942119B\r
6         for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:34 -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 Wz9t0-mK1uVB for <notmuch@notmuchmail.org>;\r
17         Wed, 29 Jun 2011 13:19:34 -0700 (PDT)\r
18 Received: from mail-iw0-f181.google.com (mail-iw0-f181.google.com\r
19         [209.85.214.181]) (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 1682B421192\r
22         for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:34 -0700 (PDT)\r
23 Received: by iwn37 with SMTP id 37so1501294iwn.26\r
24         for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:33 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:in-reply-to:date:references:user-agent:message-id\r
27         :mime-version:content-type;\r
28         bh=ENjO6I2qYFPPIaPDbf3VByFnzPJZ0BWxyH+mjSUaHMk=;\r
29         b=dMmirqkfYiJfTAp076iIOOQE9RmiKKfzyr/JzW1mC+EOpnEBKhAlHdecGt0+eRJV6z\r
30         /4Oc2dPn01bZOJlEUJD/uYnLkXrBrWvdlvbXjll9s7T+B/Q5+GQlARl8NeislRXNlYA8\r
31         3pMHKf/dtI8Zbl0NeODcoJRUETmcy9u0mBBBE=\r
32 Received: by 10.42.71.85 with SMTP id i21mr1134475icj.323.1309378773485;\r
33         Wed, 29 Jun 2011 13:19:33 -0700 (PDT)\r
34 Received: from localhost ([74.205.145.146])\r
35         by mx.google.com with ESMTPS id f13sm774812ibe.61.2011.06.29.13.19.32\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Wed, 29 Jun 2011 13:19:32 -0700 (PDT)\r
38 From: Mark Anderson <ma.skies@gmail.com>\r
39 To: Pieter Praet <pieter@praet.org>, notmuch@notmuchmail.org,\r
40  cworth@cworth.org\r
41 Subject: [PATCH] Fix folder: coherence issue\r
42 In-Reply-To: <87iprqxxp6.fsf@praet.org>\r
43 Date: Wed, 29 Jun 2011 14:04:45 -0600\r
44 References: <87sjqvw64n.fsf@gmail.com> <87iprqxxp6.fsf@praet.org>\r
45 User-Agent: Notmuch/0.5-283-gb744eac (http://notmuchmail.org) Emacs/23.2.1\r
46         (i686-pc-linux-gnu)\r
47 Message-ID: <878vskie5p.fsf@gmail.com>\r
48 MIME-Version: 1.0\r
49 Content-Type: text/plain; charset=us-ascii\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Wed, 29 Jun 2011 20:19:35 -0000\r
63 \r
64 Add removal of all ZXFOLDER terms to removal of all XFOLDER terms for\r
65 each message filename removal.\r
66 \r
67 The existing filename-list reindexing will put all the needed terms\r
68 back in.  Test search-folder-coherence now passes.\r
69 \r
70 Signed-off-by:Mark Anderson <ma.skies@gmail.com>\r
71 ---\r
72 \r
73 Once I fixed the removal instead of the addition side, things went\r
74 smoothly.\r
75 \r
76  lib/message.cc |   31 ++++++++++++++++++++++++++++---\r
77  1 files changed, 28 insertions(+), 3 deletions(-)\r
78 \r
79 diff --git a/lib/message.cc b/lib/message.cc\r
80 index 8b9c84f..d993cde 100644\r
81 --- a/lib/message.cc\r
82 +++ b/lib/message.cc\r
83 @@ -514,6 +514,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
84      const char *folder_prefix = _find_prefix ("folder");\r
85      int folder_prefix_len = strlen (folder_prefix);\r
86      void *local = talloc_new (message);\r
87 +    char *zfolder_prefix = talloc_asprintf(local, "Z%s", folder_prefix);\r
88 +    int zfolder_prefix_len = strlen (zfolder_prefix);\r
89      char *direntry;\r
90      notmuch_private_status_t private_status;\r
91      notmuch_status_t status;\r
92 @@ -530,9 +532,12 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
93      status = COERCE_STATUS (private_status,\r
94                             "Unexpected error from _notmuch_message_remove_term");\r
95  \r
96 -    /* Re-synchronize "folder:" terms for this message. This requires\r
97 -     * first removing all "folder:" terms, then adding back terms for\r
98 -     * all remaining filenames of the message. */\r
99 +    /* Re-synchronize "folder:" terms for this message. This requires:\r
100 +     *  1. removing all "folder:" terms\r
101 +     *  2. removing all "folder:" stemmed terms\r
102 +     *  3. adding back terms for all remaining filenames of the message. */\r
103 +\r
104 +    /* 1. removing all "folder:" terms */\r
105      while (1) {\r
106         i = message->doc.termlist_begin ();\r
107         i.skip_to (folder_prefix);\r
108 @@ -551,6 +556,26 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
109         }\r
110      }\r
111  \r
112 +    /* 2. removing all "folder:" stemmed terms */\r
113 +    while (1) {\r
114 +       i = message->doc.termlist_begin ();\r
115 +       i.skip_to (zfolder_prefix);\r
116 +\r
117 +       /* Terminate loop when no terms remain with desired prefix. */\r
118 +       if (i == message->doc.termlist_end () ||\r
119 +           strncmp ((*i).c_str (), zfolder_prefix, zfolder_prefix_len))\r
120 +       {\r
121 +           break;\r
122 +       }\r
123 +\r
124 +       try {\r
125 +           message->doc.remove_term ((*i));\r
126 +       } catch (const Xapian::InvalidArgumentError) {\r
127 +           /* Ignore failure to remove non-existent term. */\r
128 +       }\r
129 +    }\r
130 +\r
131 +    /* 3. adding back terms for all remaining filenames of the message. */\r
132      i = message->doc.termlist_begin ();\r
133      i.skip_to (direntry_prefix);\r
134  \r
135 -- \r
136 1.7.4.1\r