]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-index-message.cc
Minor code re-ordering for clarity.
[notmuch] / notmuch-index-message.cc
index 44b1b03a1e180bc8625b13dcd02f8ddf73f1a453..6f0b21e73b7dd2175a0ace0e6ae220745bdcaccc 100644 (file)
@@ -187,6 +187,23 @@ add_terms_address_addrs (Xapian::Document doc,
     }
 }
 
+static const char *
+skip_re_in_subject (const char *subject)
+{
+    const char *s = subject;
+
+    while (*s) {
+       while (*s && isspace (*s))
+           s++;
+       if (strncasecmp (s, "re:", 3) == 0)
+           s += 3;
+       else
+           break;
+    }
+
+    return s;
+}
+
 /* Generate terms for the body of a message, given the filename of the
  * message and the offset at which the headers of the message end,
  * (and hence the body begins). */
@@ -337,6 +354,7 @@ main (int argc, char **argv)
        gen_terms_address_names (term_gen, addresses, "to_name");
 
        value = g_mime_message_get_subject (message);
+       value = skip_re_in_subject (value);
        gen_terms (term_gen, "subject", value);
        gen_terms (term_gen, "body", value);
 
@@ -367,12 +385,10 @@ main (int argc, char **argv)
        add_term (doc, "label", "inbox");
        add_term (doc, "label", "unread");
        add_term (doc, "type", "mail");
+       add_term (doc, "source_id", "1");
 
        value = g_mime_message_get_message_id (message);
        add_term (doc, "msgid", value);
-
-       add_term (doc, "source_id", "1");
-
        add_term (doc, "thread", value);
 
        doc.add_value (NOTMUCH_VALUE_MESSAGE_ID, value);