+static void
+_thread_set_subject_from_message (notmuch_thread_t *thread,
+ notmuch_message_t *message)
+{
+ const char *subject;
+ const char *cleaned_subject;
+
+ subject = notmuch_message_get_header (message, "subject");
+ if (! subject)
+ return;
+
+ if ((strncasecmp (subject, "Re: ", 4) == 0) ||
+ (strncasecmp (subject, "Aw: ", 4) == 0) ||
+ (strncasecmp (subject, "Vs: ", 4) == 0) ||
+ (strncasecmp (subject, "Sv: ", 4) == 0)) {
+
+ cleaned_subject = talloc_strndup (thread,
+ subject + 4,
+ strlen(subject) - 4);
+ } else {
+ cleaned_subject = talloc_strdup (thread, subject);
+ }
+
+ if (thread->subject)
+ talloc_free (thread->subject);
+
+ thread->subject = talloc_strdup (thread, cleaned_subject);
+}
+