From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aHS8Arl3v2HDbwAAgWs5BA (envelope-from ) for ; Sun, 19 Dec 2021 19:19:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8FwFOrh3v2F2eAAA1q6Kng (envelope-from ) for ; Sun, 19 Dec 2021 18:19:36 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A9CA1882E for ; Sun, 19 Dec 2021 19:19:36 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 327132934F; Sun, 19 Dec 2021 13:19:16 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id DF29027E1E for ; Sun, 19 Dec 2021 13:19:06 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id B8F435FC48; Sun, 19 Dec 2021 13:19:06 -0500 (EST) Received: (nullmailer pid 115981 invoked by uid 1000); Sun, 19 Dec 2021 18:19:03 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC Patch 1/3] CLI/address: refactor/inline print_popular Date: Sun, 19 Dec 2021 14:18:52 -0400 Message-Id: <20211219181854.115918-2-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211219181854.115918-1-david@tethera.net> References: <20211219181854.115918-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: OVLOZYL6RJM7FHMCOQOFK32CSMPETVBL X-Message-ID-Hash: OVLOZYL6RJM7FHMCOQOFK32CSMPETVBL X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: FR ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639937976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=c/HmktWRbX3E3utRLfHCixmWyCnHCX4EdZA11NcSH30=; b=a+rzHaQeIknRovTsEsdsbd89IQUz4ibCsomNN6GweUr7t2W2CvcyDETdevIWPDRdqJ+Tlu e9NAshaWIqkGYGKiBk5P6dTjoDJZQR9l5fvGPep33FcEMi0H+FJp3AyYOgH0ceDN8HiIhU k05ERkfLRDEKeSLKS4iYTuP0FoJDigcqtLJzVZpm0snwRwo39YUQm22KdsT/EXUVr8yTSO SAUP8obNrnQiJqniscdG006MOvG1XiPCUrxdPzk10G9tUdKKzTuxx+7nXjGPjmUBDCcse6 uyQGAUC/0dG8BIgfRk25ng5P/zCb3Ha+m18cXCIm/kec+YphW9PpkzyC5yYS0w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639937976; a=rsa-sha256; cv=none; b=bCSpjeqRr79KKOva6BgyX4wRSWomhT+fCkoQSit/ARpn1Mps1d4BJfPvWo86wZVbVkXqJL 1YRwjTbAfkJfc82ZITV759PO0W5Ql1Rl+rRfjWxwCB8xOEtRANbTN5G6PZpMY0ysnlaeOo ib2kgYVBi1dEB/9ShQ7/UUIN8gI3yOeeWhQVz6SjpwTYNOx1ROdcqymSxEh/C/YNz0IBrQ 79ZUxo8S3cyqPTxB8ZGSDXhBtJ6aiT9cPZYyu4FKPm/8HLeNq6MyxhUrYQXi1qEfOPkJyo D9AzJI4dkI3aW6NTVFpU5It2ZCXIX5BDvSOqhp+cCN/YWQwYgz1mAsd5pAuMOw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.47 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A9CA1882E X-Spam-Score: -0.47 X-Migadu-Scanner: scn0.migadu.com X-TUID: SMfl+02EgXg0 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