mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
notmuch search: Print the names of author of matched emails.
It's important to have the names present for determining whether a thread is worth reading or not. We may want to think about abbreviating the list somehow if it is excessively long (or redundant as in bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, etc.).
This commit is contained in:
parent
4d35c3544d
commit
2f4c587474
3 changed files with 51 additions and 1 deletions
|
@ -451,6 +451,20 @@ notmuch_threads_destroy (notmuch_threads_t *threads);
|
||||||
const char *
|
const char *
|
||||||
notmuch_thread_get_thread_id (notmuch_thread_t *thread);
|
notmuch_thread_get_thread_id (notmuch_thread_t *thread);
|
||||||
|
|
||||||
|
/* Get the authors of 'thread'
|
||||||
|
*
|
||||||
|
* The returned string is a comma-separated list of the names of the
|
||||||
|
* authors of mail messages in the query results that belong to this
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* The returned string belongs to 'thread' and as such, should not be
|
||||||
|
* modified by the caller and will only be valid for as long as the
|
||||||
|
* thread is valid, (which is until notmuch_thread_destroy or until
|
||||||
|
* the query from which it derived is destroyed).
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
notmuch_thread_get_authors (notmuch_thread_t *thread);
|
||||||
|
|
||||||
/* Get the subject of 'thread'
|
/* Get the subject of 'thread'
|
||||||
*
|
*
|
||||||
* The subject is taken from the first message (according to the query
|
* The subject is taken from the first message (according to the query
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
|
|
||||||
#include <xapian.h>
|
#include <xapian.h>
|
||||||
|
|
||||||
|
#include <gmime/gmime.h>
|
||||||
#include <glib.h> /* GHashTable */
|
#include <glib.h> /* GHashTable */
|
||||||
|
|
||||||
struct _notmuch_thread {
|
struct _notmuch_thread {
|
||||||
notmuch_database_t *notmuch;
|
notmuch_database_t *notmuch;
|
||||||
char *thread_id;
|
char *thread_id;
|
||||||
char *subject;
|
char *subject;
|
||||||
|
char *authors;
|
||||||
GHashTable *tags;
|
GHashTable *tags;
|
||||||
|
|
||||||
notmuch_bool_t has_message;
|
notmuch_bool_t has_message;
|
||||||
|
@ -75,6 +77,7 @@ _notmuch_thread_create (const void *talloc_owner,
|
||||||
thread->notmuch = notmuch;
|
thread->notmuch = notmuch;
|
||||||
thread->thread_id = talloc_strdup (thread, thread_id);
|
thread->thread_id = talloc_strdup (thread, thread_id);
|
||||||
thread->subject = NULL;
|
thread->subject = NULL;
|
||||||
|
thread->authors = NULL;
|
||||||
thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,
|
thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
free, NULL);
|
free, NULL);
|
||||||
|
|
||||||
|
@ -98,6 +101,32 @@ _notmuch_thread_add_message (notmuch_thread_t *thread,
|
||||||
notmuch_tags_t *tags;
|
notmuch_tags_t *tags;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
time_t date;
|
time_t date;
|
||||||
|
InternetAddressList *list;
|
||||||
|
InternetAddress *address;
|
||||||
|
const char *from, *author;
|
||||||
|
|
||||||
|
from = notmuch_message_get_header (message, "from");
|
||||||
|
list = internet_address_list_parse_string (from);
|
||||||
|
if (list) {
|
||||||
|
address = internet_address_list_get_address (list, 0);
|
||||||
|
if (address) {
|
||||||
|
author = internet_address_get_name (address);
|
||||||
|
if (author == NULL) {
|
||||||
|
InternetAddressMailbox *mailbox;
|
||||||
|
mailbox = INTERNET_ADDRESS_MAILBOX (address);
|
||||||
|
author = internet_address_mailbox_get_addr (mailbox);
|
||||||
|
}
|
||||||
|
if (author) {
|
||||||
|
if (thread->authors)
|
||||||
|
thread->authors = talloc_asprintf (thread, "%s, %s",
|
||||||
|
thread->authors,
|
||||||
|
author);
|
||||||
|
else
|
||||||
|
thread->authors = talloc_strdup (thread, author);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_object_unref (G_OBJECT (list));
|
||||||
|
}
|
||||||
|
|
||||||
if (! thread->subject) {
|
if (! thread->subject) {
|
||||||
const char *subject;
|
const char *subject;
|
||||||
|
@ -124,6 +153,12 @@ _notmuch_thread_add_message (notmuch_thread_t *thread,
|
||||||
thread->has_message = 1;
|
thread->has_message = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
notmuch_thread_get_authors (notmuch_thread_t *thread)
|
||||||
|
{
|
||||||
|
return thread->authors;
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
notmuch_thread_get_subject (notmuch_thread_t *thread)
|
notmuch_thread_get_subject (notmuch_thread_t *thread)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,9 +64,10 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
|
||||||
date = notmuch_thread_get_oldest_date (thread);
|
date = notmuch_thread_get_oldest_date (thread);
|
||||||
relative_date = notmuch_time_relative_date (ctx, date);
|
relative_date = notmuch_time_relative_date (ctx, date);
|
||||||
|
|
||||||
printf ("thread:%s %12s %s",
|
printf ("thread:%s %12s %s; %s",
|
||||||
notmuch_thread_get_thread_id (thread),
|
notmuch_thread_get_thread_id (thread),
|
||||||
relative_date,
|
relative_date,
|
||||||
|
notmuch_thread_get_authors (thread),
|
||||||
notmuch_thread_get_subject (thread));
|
notmuch_thread_get_subject (thread));
|
||||||
|
|
||||||
printf (" (");
|
printf (" (");
|
||||||
|
|
Loading…
Reference in a new issue