Austin Clements <[email protected]> writes:
> I'd say this patch looks good other than coding style
> - Tab indentation
> - /* */ comments, starting with a capital letter
> - Space between function name and open paren
> - Space after comma in argument lists
> - Spaces around assignment operator
Thanks, fixed the ones I see:
diff --git a/lib/database.cc b/lib/database.cc
index 9c2f4ec..63a15bb 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1654,7 +1654,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
goto DONE;
date = notmuch_message_file_get_header (message_file, "date");
- _notmuch_message_set_date (message, date);
+ _notmuch_message_set_header_values (message, date, from, subject);
_notmuch_message_index_file (message, filename);
} else {
diff --git a/lib/message.cc b/lib/message.cc
index d993cde..55070c6 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -410,6 +410,21 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)
const char *
notmuch_message_get_header (notmuch_message_t *message, const char *header)
{
+ std::string value;
+
+ /* Fetch header from the appropriate xapian value field if
+ * available */
+ if (strcmp(header, "from") == 0)
+ value = message->doc.get_value(NOTMUCH_VALUE_FROM);
+ else if (strcmp(header, "subject") == 0)
+ value = message->doc.get_value (NOTMUCH_VALUE_SUBJECT);
+ else if (strcmp(header, "message-id") == 0)
+ value = message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);
+
+ if (!value.empty())
+ return talloc_strdup (message, value.c_str ());
+
+ /* Otherwise fall back to parsing the file */
_notmuch_message_ensure_message_file (message);
if (message->message_file == NULL)
return NULL;
@@ -785,8 +800,10 @@ notmuch_message_set_author (notmuch_message_t *message,
}
void
-_notmuch_message_set_date (notmuch_message_t *message,
- const char *date)
+_notmuch_message_set_header_values (notmuch_message_t *message,
+ const char *date,
+ const char *from,
+ const char *subject)
{
time_t time_value;
@@ -799,6 +816,8 @@ _notmuch_message_set_date (notmuch_message_t *message,
message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP,
Xapian::sortable_serialise (time_value));
+ message->doc.add_value (NOTMUCH_VALUE_FROM, from);
+ message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
}
/* Synchronize changes made to message->doc out into the database. */
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 02e24ee..2e91afd 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -111,7 +111,9 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2);
typedef enum {
NOTMUCH_VALUE_TIMESTAMP = 0,
- NOTMUCH_VALUE_MESSAGE_ID
+ NOTMUCH_VALUE_MESSAGE_ID,
+ NOTMUCH_VALUE_FROM,
+ NOTMUCH_VALUE_SUBJECT
} notmuch_value_t;
/* Xapian (with flint backend) complains if we provide a term longer
@@ -287,9 +289,10 @@ void
_notmuch_message_ensure_thread_id (notmuch_message_t *message);
void
-_notmuch_message_set_date (notmuch_message_t *message,
- const char *date);
-
+_notmuch_message_set_header_values (notmuch_message_t *message,
+ const char *date,
+ const char *from,
+ const char *subject);
void
_notmuch_message_sync (notmuch_message_t *message);
--
Istvan
_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch