[PATCH 11/11] lib: add recipients to database

Michal Sojka sojkam1 at fel.cvut.cz
Fri Aug 31 14:34:12 PDT 2012


On Mon, Aug 20 2012, Jameson Graef Rollins wrote:
> This adds just the "to" recipients, but probably "cc"s should be
> included as well.
> ---
>  lib/database.cc       |    2 +-
>  lib/message.cc        |    4 ++++
>  lib/notmuch-private.h |    2 ++
>  3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 761dc1a..4c1d578 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -1814,7 +1814,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
>  		goto DONE;
>  
>  	    date = notmuch_message_file_get_header (message_file, "date");
> -	    _notmuch_message_set_header_values (message, date, from, subject);
> +	    _notmuch_message_set_header_values (message, date, from, to, subject);
>  
>  	    _notmuch_message_index_file (message, filename);
>  	} else {
> diff --git a/lib/message.cc b/lib/message.cc
> index fa28073..cc5c8a0 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -420,6 +420,8 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
>       * available */
>      if (strcasecmp (header, "from") == 0)
>  	value = message->doc.get_value (NOTMUCH_VALUE_FROM);
> +    if (strcasecmp (header, "to") == 0)
> +	value = message->doc.get_value (NOTMUCH_VALUE_TO);
>      else if (strcasecmp (header, "subject") == 0)
>  	value = message->doc.get_value (NOTMUCH_VALUE_SUBJECT);
>      else if (strcasecmp (header, "message-id") == 0)
> @@ -830,6 +832,7 @@ void
>  _notmuch_message_set_header_values (notmuch_message_t *message,
>  				    const char *date,
>  				    const char *from,
> +				    const char *to,
>  				    const char *subject)
>  {
>      time_t time_value;
> @@ -844,6 +847,7 @@ _notmuch_message_set_header_values (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_TO, to);
>      message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
>  }
>  
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 32d1523..f56c580 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -95,6 +95,7 @@ typedef enum {
>      NOTMUCH_VALUE_TIMESTAMP = 0,
>      NOTMUCH_VALUE_MESSAGE_ID,
>      NOTMUCH_VALUE_FROM,
> +    NOTMUCH_VALUE_TO,

It would be definitely useful to add other headers to the database (and
make them searchable). As far as I remember this is on the todo list for
ages. I'm only not sure that the approach of adding every possible
header manually (like in this patch) is a good approach. Emails can
contain arbitrary headers so there would be always some header missing.
I'm not that much familiar with Xapian to figure out how to implement
this.

Otherwise this series looks quite well. I'm only not sure whether to
merge it now or after changing the storage of headers in the database.

Probably, if emacs interface is also extended to use this feature as
part of saved searches or hello-section in a way that I can see the list
of drafts on one click from hello screen. I'd vote for merging this now.

However, I've just looked how does my drafts folder (messages saved with
C-x C-s) looks like and one problem I see there is that draft messages
do not have message ids. Do you have an idea how to implement drafts in
emacs UI?

Thanks,
-Michal



More information about the notmuch mailing list