From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [RFC Patch 1/3] CLI/address: refactor/inline print_popular
Date: Sun, 19 Dec 2021 14:18:52 -0400 [thread overview]
Message-ID: <20211219181854.115918-2-david@tethera.net> (raw)
In-Reply-To: <20211219181854.115918-1-david@tethera.net>
The goal is to make it easier to sort the current output in future commits.
There should be no functional change in this commit.
---
notmuch-search.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/notmuch-search.c b/notmuch-search.c
index 327e1445..47eec601 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -473,10 +473,10 @@ _list_free_for_g_hash (void *ptr)
g_list_free_full (ptr, _talloc_free_for_g_hash);
}
-/* Print the most common variant of a list of unique mailboxes, and
+/* Find the most common variant of a list of unique mailboxes, and
* conflate the counts. */
-static void
-print_popular (const search_context_t *ctx, GList *list)
+static mailbox_t *
+summarize_mailboxes (GList *list)
{
GList *l;
mailbox_t *mailbox = NULL, *m;
@@ -498,7 +498,7 @@ print_popular (const search_context_t *ctx, GList *list)
/* The original count is no longer needed, so overwrite. */
mailbox->count = total;
- print_mailbox (ctx, mailbox);
+ return mailbox;
}
static void
@@ -512,9 +512,10 @@ print_hash_value (unused (void *key), void *list, void *context)
{
const search_context_t *ctx = context;
- if (ctx->dedup == DEDUP_ADDRESS)
- print_popular (ctx, list);
- else
+ if (ctx->dedup == DEDUP_ADDRESS) {
+ mailbox_t *mailbox = summarize_mailboxes (list);
+ print_mailbox (ctx, mailbox);
+ } else
g_list_foreach (list, print_list_value, context);
}
@@ -619,9 +620,9 @@ do_search_messages (search_context_t *ctx)
}
if (ctx->addresses &&
- (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS))
+ (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS)) {
g_hash_table_foreach (ctx->addresses, print_hash_value, ctx);
-
+ }
notmuch_messages_destroy (messages);
format->end (format);
--
2.34.1
next prev parent reply other threads:[~2021-12-19 18:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-19 18:18 Partial support for sorting the output of notmuch address David Bremner
2021-12-19 18:18 ` David Bremner [this message]
2021-12-19 18:18 ` [RFC Patch 2/3] CLI/address: sort output by frequency with deduplicate=address David Bremner
2021-12-19 18:18 ` [RFC Patch 3/3] CLI/address: source by frequency if output=count David Bremner
2021-12-20 16:48 ` Partial support for sorting the output of notmuch address inwit
2021-12-20 17:44 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211219181854.115918-2-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).