[PATCH 0/5] cli: alternative address deduplication

2015-08-29 Thread Jani Nikula
This series adds support both for not deduplicating addresses in notmuch address, and for using just the case insensitive address part of an email address. The new deduplication picks the most popular variant. Real life examples, current deduplication: $ notmuch address --output=count

[RFC PATCH 2/5] cli: abstract new mailbox creation

2015-08-29 Thread Jani Nikula
We'll be needing more mailbox creation soon, so abstract it away. While at it, check for allocation failures. No other functional changes. --- notmuch-search.c | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index

[RFC PATCH 1/5] cli: g_hash_table_lookup_extended is overkill

2015-08-29 Thread Jani Nikula
Switch to normal glib hash table lookup. The extended version is only required if the values may contain NULL. --- notmuch-search.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 3076c3f637b1..7fdc6acaa2fe

[RFC PATCH 3/5] cli: add support for not deduplicating notmuch address results

2015-08-29 Thread Jani Nikula
Make it possible to use notmuch address as part of a | sort | uniq -c pipe instead of forcing --output=count. This is useful for combining results from multiple notmuch address queries. --- notmuch-search.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/notmuch-search.c

[RFC PATCH 4/5] cli: change the data structure for notmuch address deduplication

2015-08-29 Thread Jani Nikula
Currently we key the address hash table with the case sensitive name address. Switch to case insensitive keying with just address, and store the case sensitive name and address in linked lists. This will be helpful in adding support different deduplication schemes in the future. There will be a

Re: [RFC PATCH 4/5] cli: change the data structure for notmuch address deduplication

2015-08-29 Thread David Bremner
Jani Nikula j...@nikula.org writes: +static int +strcase_equal (const void *a, const void *b) +{ +return strcasecmp (a, b) == 0; +} + +static unsigned int +strcase_hash (const void *ptr) +{ +const char *s = ptr; + +/* This is the djb2 hash. */ +unsigned int hash =

Re: [RFC PATCH 3/5] cli: add support for not deduplicating notmuch address results

2015-08-29 Thread David Bremner
Jani Nikula j...@nikula.org writes: + { NOTMUCH_OPT_KEYWORD, ctx-dupe, deduplicate, 'x', probably you want 'D' or 'd' here. Not that it makes a practical difference at this point. + (notmuch_keyword_t []){ { yes, -1 }, I'm not very enthusiastic about reusing ctx-dupe for this. In