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 uOgXOBMtQ2HvdAEAgWs5BA (envelope-from ) for ; Thu, 16 Sep 2021 13:40:03 +0200 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 mFDoMxMtQ2GDPwAA1q6Kng (envelope-from ) for ; Thu, 16 Sep 2021 11:40:03 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6A6F91C7CC for ; Thu, 16 Sep 2021 13:40:03 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2B69326C8C; Thu, 16 Sep 2021 07:39:52 -0400 (EDT) Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by mail.notmuchmail.org (Postfix) with ESMTPS id 3BA8B26871 for ; Thu, 16 Sep 2021 06:25:24 -0400 (EDT) Received: by mail-ed1-x52d.google.com with SMTP id z94so14816708ede.8 for ; Thu, 16 Sep 2021 03:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rammhold-de.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2qJ/Azn/2UueMq9VtuTIQVq1Pt11wh09VctO7FqV/T4=; b=dIsOZFVSTfrdWZPsNOeBwxhhBGX7KMwrIh+wbreC050uRhsNCs02OKCEoEYkaP6nnZ Vrx6xlgf4No5H4ABJlq4r7jQ6nHW9lvAxoAvSfyJeIFUGpVYXVFzrukT3ncY2k+hdnfP 9QjQENxGxD0qh7FTDjxdRp5bg+kilV90iOpZ3TGv0XvDM59zh3wng9XWuRWHLG3CJQQJ BVSVmHx5759ygOMyN42fo6PjYAfLULURaCnCIuGbEjG5uRYAEwVcFV85y0rPHRtJoi0M 24/bKIhe4ATbJC2zr8ettCOy3J9Du/DDNyf9zijIQZWUJQtM90PnG0ddRmNdX6VP2guv zYvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2qJ/Azn/2UueMq9VtuTIQVq1Pt11wh09VctO7FqV/T4=; b=bhMJG9oiFQaLJr8BnaEFuX2wcumFTCpWn8fkGlVFpluXwhGoHZy3IBUtB/FdiHqjnY jLcAH0ew+6pyFJhY3sGCle8h/BaZYkGxpn9+BwnpCwWsS+zVvslhn1vOxyQ+sEZiTiKj 0JNRPuTFkmnj7LwEu/YHff5RazTBZv2gUNyV1cJTjwY427go2DNP2e6XL7IgGJAe7A3G qVAFCoW8AJeU+SAT1S1B9jihZO5LCrVamPa6S0lhrcmdT6SJtMmS8WgNblqYwlcHmqZ3 M0k3VYDENvAf73Y7e7n+R1ZkYhDXUHQfC/HXPu5ew0iQmMU+PMg+ilqIIvwij9vcESty MfGQ== X-Gm-Message-State: AOAM530v0ByoxaSGbWNPC0CWnAGvV3Tk+84YU0Wywryu25Jicke1HIgj rKd2jBpwJr3ZKtecIAG2hu4NE1Mm92JHPw== X-Google-Smtp-Source: ABdhPJzJWD+DdbnydYR5fVfV01JxoKbHRzzBD1LaMPfjNiVb37XJBlCGr8gt5voMFNoUIhIxXISh9Q== X-Received: by 2002:a17:906:311b:: with SMTP id 27mr5468700ejx.428.1631787922471; Thu, 16 Sep 2021 03:25:22 -0700 (PDT) Received: from localhost ([2a00:e67:5c9:a:2e15:c474:2ef7:bc26]) by smtp.gmail.com with ESMTPSA id b8sm1186697edv.96.2021.09.16.03.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 03:25:21 -0700 (PDT) From: andreas@rammhold.de To: notmuch@notmuchmail.org Subject: [RFC 2/2] CLI/notmuch: add --new-tags argument to notmuch-new(1) Date: Thu, 16 Sep 2021 12:25:17 +0200 Message-Id: <20210916102517.1744389-3-andreas@rammhold.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916102517.1744389-1-andreas@rammhold.de> References: <20210916102517.1744389-1-andreas@rammhold.de> MIME-Version: 1.0 X-MailFrom: andreas@rammhold.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 Message-ID-Hash: E2H7PVOS3A7TTWT4UIDWDYF25ITPN2BC X-Message-ID-Hash: E2H7PVOS3A7TTWT4UIDWDYF25ITPN2BC X-Mailman-Approved-At: Thu, 16 Sep 2021 11:39:48 -0400 CC: Andreas Rammhold X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631792403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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-unsubscribe:list-subscribe:list-post:dkim-signature; bh=yd+b5t42Cigj01aPqy4TVVdSvJ3g6mqmAoaa1RA51qA=; b=P5tNckMS5Wzxa7ZSjj6XypQ5Tb89jcQUp4FokrzV60PAl1psoLQsJKI++BRoFypCeYiYDt 5NpJxR3wo+Oi99dYqiN8bujE/OzpgvzenyqFsjJHtCR4hUBryvxdEBj5i7FGBIO4Y5Ug8i R9nClq/wwTpLaSRcO0mgMCbeCu0B2yCMdVg7yH2303UNCfQBIWZ4SYLRZvZRX1Sh+02WXY 7UMtgx0HEeWICf9lF+95Y/75NLf6VcdbEEXg9KpyIeQx7UUr7v4DEgaiNAKumI7XUwQC8l jWe+3j0En676UqyOsKwfSJvzOxOv+VeEIb+roQqH5UfYL9FgXGG0meXhaelbtA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631792403; a=rsa-sha256; cv=none; b=tjjfSAcTGpG+6/ICaQl3S+k4ekdvtHLPJ25J3yVm+/43tWYusUDPr1qLbYA9r00/i8Mgw3 W3qyKEq79z70aYlmnBqQ6umEoZCvtDRKSWw8LqrUkJV++Q+ZOtLgsXCMki8Ok1RGUXbgjW l8ICVmB7uD+TUC9WK+YYLjX/0+h59Zzk8+IObl51h+EGo+o8rV6VI889onbKSiQNKccTI8 MXgHzaOsOCfaIL53PnY12iAd4pAjGV0Utl6NGfhcfsNIKswrIdNQo2PR7Fe97hPtP7M+XD z5Vmrg84U8olbjluuzaR5odL19eWt8o8Lnt/L5pnOg3YwdUuNjNtA/JYhknFbw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=rammhold-de.20150623.gappssmtp.com header.s=20150623 header.b=dIsOZFVS; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 1.39 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=rammhold-de.20150623.gappssmtp.com header.s=20150623 header.b=dIsOZFVS; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6A6F91C7CC X-Spam-Score: 1.39 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8IqEHFr29Nuj From: Andreas Rammhold This introduces a new argument to notmuch-new(1) that allows specfying the tags that should be applied to new messages. The new option takes precedence over the new.tags setting configured in the configuration file. The need for this option did arise while due to race-conditions between notmuch tagging messages as new, running my post-new hook and unsetting the new tag as last step of my processing. --- doc/man1/notmuch-new.rst | 7 +++++++ notmuch-new.c | 16 +++++++++++++++- test/T050-new.sh | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst index 9cb4a54e..d1ed5536 100644 --- a/doc/man1/notmuch-new.rst +++ b/doc/man1/notmuch-new.rst @@ -78,6 +78,13 @@ Supported options for **new** include to optimize the scanning of directories for new mail. This option turns that optimization off. +.. option:: --new-tags= + + If set defines an alternative value for the new tags that will be applied to + all newly added messages. + + See also ``new.tags`` in :any:`notmuch-config(1)`. + EXIT STATUS =========== diff --git a/notmuch-new.c b/notmuch-new.c index b7a5f2ea..80ef35d5 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -1125,6 +1125,8 @@ notmuch_new_command (notmuch_database_t *notmuch, int argc, char *argv[]) bool timer_is_active = false; bool hooks = true; bool quiet = false, verbose = false; + const char *new_tags = NULL; + notmuch_config_values_t *new_tags_config = NULL; notmuch_status_t status; notmuch_opt_desc_t options[] = { @@ -1133,6 +1135,7 @@ notmuch_new_command (notmuch_database_t *notmuch, int argc, char *argv[]) { .opt_bool = &add_files_state.debug, .name = "debug" }, { .opt_bool = &add_files_state.full_scan, .name = "full-scan" }, { .opt_bool = &hooks, .name = "hooks" }, + { .opt_string = &new_tags, .name = "new-tags" }, { .opt_inherit = notmuch_shared_indexing_options }, { .opt_inherit = notmuch_shared_options }, { } @@ -1150,7 +1153,15 @@ notmuch_new_command (notmuch_database_t *notmuch, int argc, char *argv[]) else if (verbose) add_files_state.verbosity = VERBOSITY_VERBOSE; - add_files_state.new_tags = notmuch_config_get_values (notmuch, NOTMUCH_CONFIG_NEW_TAGS); + if (! new_tags) { + add_files_state.new_tags = notmuch_config_get_values (notmuch, NOTMUCH_CONFIG_NEW_TAGS); + } else { + new_tags_config = notmuch_config_values_from_string (notmuch, new_tags); + if (! new_tags_config) + return EXIT_FAILURE; + + add_files_state.new_tags = new_tags_config; + } if (print_status_database ( "notmuch new", @@ -1290,6 +1301,9 @@ notmuch_new_command (notmuch_database_t *notmuch, int argc, char *argv[]) talloc_free (add_files_state.removed_directories); talloc_free (add_files_state.directory_mtimes); + if (new_tags_config) + talloc_free (new_tags_config); + if (timer_is_active) stop_progress_printing_timer (); diff --git a/test/T050-new.sh b/test/T050-new.sh index 1141c1e3..6b6f5071 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -37,6 +37,12 @@ test_begin_subtest "No new messages (full-scan)" output=$(NOTMUCH_NEW --debug --full-scan 2>&1) test_expect_equal "$output" "No new mail." +test_begin_subtest "Single new message with custom tags" +generate_message +NOTMUCH_NEW --debug --new-tags="foo-new;bar-new" +output=$(notmuch count tag:foo-new and tag:bar-new) +test_expect_equal "$output" "1" + test_begin_subtest "New directories" rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch mkdir "${MAIL_DIR}"/def -- 2.32.0