]> git.notmuchmail.org Git - notmuch/commitdiff
index: Store "Full Name <user@example.com>" addressses in the database
authorCarl Worth <cworth@cworth.org>
Wed, 28 Oct 2009 20:09:08 +0000 (13:09 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 28 Oct 2009 20:09:08 +0000 (13:09 -0700)
We put these is as a separate term so that they can be extracted.
We don't actually need this for searching, since typing an email
address in as a search term will already trigger a phrase search
that does exactly what's wanted.

database.cc
index.cc

index 583bee82a2d3d95b81814002ac042489484a5122..b7fb1f1071a2d6a544e32733c046470b3dcb44bf 100644 (file)
@@ -106,6 +106,7 @@ prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
     { "type", "T" },
     { "ref", "XREFERENCE" },
     { "timestamp", "XTIMESTAMP" },
     { "type", "T" },
     { "ref", "XREFERENCE" },
     { "timestamp", "XTIMESTAMP" },
+    { "contact", "XCONTACT" }
 };
 
 prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
 };
 
 prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
index 88634fc76ed784beb853581abf579dd595e4ac56..b51d22617a3184b3fde14238a2e72853643ddb58 100644 (file)
--- a/index.cc
+++ b/index.cc
@@ -30,13 +30,23 @@ _index_address_mailbox (notmuch_message_t *message,
                        InternetAddress *address)
 {
     InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
                        InternetAddress *address)
 {
     InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
-    const char *name, *addr = internet_address_mailbox_get_addr (mailbox);
+    const char *name, *addr;
+    char *contact;
     int own_name = 0;
 
     int own_name = 0;
 
-    if (addr)
-       _notmuch_message_gen_terms (message, prefix_name, addr);
-
     name = internet_address_get_name (address);
     name = internet_address_get_name (address);
+    addr = internet_address_mailbox_get_addr (mailbox);
+
+    if (addr) {
+       if (name) {
+           contact = talloc_asprintf (message, "\"%s\" <%s>",
+                                      name, addr);
+           _notmuch_message_add_term (message, "contact", contact);
+           talloc_free (contact);
+       } else {
+           _notmuch_message_add_term (message, "contact", addr);
+       }
+    }
 
     /* In the absence of a name, we'll strip the part before the @
      * from the address. */
 
     /* In the absence of a name, we'll strip the part before the @
      * from the address. */
@@ -52,6 +62,8 @@ _index_address_mailbox (notmuch_message_t *message,
 
     if (name)
        _notmuch_message_gen_terms (message, prefix_name, name);
 
     if (name)
        _notmuch_message_gen_terms (message, prefix_name, name);
+    if (addr)
+       _notmuch_message_gen_terms (message, prefix_name, addr);
 }
 
 static void
 }
 
 static void