From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GJB6LZ+2m2KoLwEAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 21:46:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8Hh4LZ+2m2L2SgAAauVa8A (envelope-from ) for ; Sat, 04 Jun 2022 21:46:39 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (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 4B2E78DBC for ; Sat, 4 Jun 2022 21:46:39 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4D2B45F7C3; Sat, 4 Jun 2022 19:38:31 +0000 (UTC) Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by mail.notmuchmail.org (Postfix) with ESMTPS id A57045F7B9 for ; Sat, 4 Jun 2022 19:38:27 +0000 (UTC) Received: from fencepost.gnu.org ([2001:470:142:3::e]:58302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxZbL-0002zF-UP; Sat, 04 Jun 2022 15:38:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=Sf1tE4tPtRFSHbMr/g8OBjYX9T7MHiDSd0Gtvhd3bzk=; b=kDM3OomcZmcnpP f0kjG9l4bsOhDIHO3SpHxSBosfA3wQVw8MnwEzPOCmOCue7hbVJaTZ7ztOOI1QKjFRQq6BwDShhuM FSN2QrHuqqAEj+oPNN9QrRzBRWmP1BLVnC1iIYfj9mNpcPOnH/BJsHAfzLmocen+rttNIt1zNmD/s tn5rL/2snd4cRjdrItNOtJsWCD89t8ACOCMdlmlQB8k6R2uo5fr409BGmi2t55zN7ZEvIS915rsQa NQ3rVBQ9cZqD/Re+rdRy7i4PjZDZelcN1SlEH8O/YHkupo5CwlmjZZ4U/nn+XISBRUOj/M5aK+NcJ /DOTu3Owyr5VBR8KjViA==; Received: from [92.233.85.247] (port=45472 helo=rivendell.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxZbL-0005Gd-GV; Sat, 04 Jun 2022 15:38:23 -0400 From: jao To: notmuch@notmuchmail.org Subject: [PATCH] emacs: use message-dont-reply-to-names when composing replies Date: Sat, 4 Jun 2022 20:38:13 +0100 Message-Id: <20220604193813.2358451-1-jao@gnu.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Message-ID-Hash: L4PD7U6VS7LXBU3MWY2J3UVCTBL7YF7E X-Message-ID-Hash: L4PD7U6VS7LXBU3MWY2J3UVCTBL7YF7E X-MailFrom: jao@gnu.org 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 CC: jao 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-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654371999; 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:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=RobJDV/gUNu7AI57WdwGriPChrPES0SUcwv1gFZhv18=; b=a847BJy45dgZrYYfyvhDoudQ5usUe33XNEMQF0O5Mkrtgb9bWLrto8VVkAAsiNtFBqiz2G 4HNFanl/l1oP6UmNxa4ZCK/ayg+IEgGv317MXhkBp42lHDJ+KPY9UHmuorhk5jfFHC1BOX Kf6/mivEZ9Hr7vKHYLCbEGwWkyh3lfYBQeaof8tTmuKSit0O5TUz30OijqjoXBehEphqKF jI6iigz+mYhZC0+YaHBj0DJxJXcUOtA585COH0+lbdvu7lqUymv387wE76QAkZfdYVXILp waIam+wKkVfqomH9TLjlSW9fS8oJ9Ddyl04zzFfIVI8vkTUkmDJZVV3pAtLfIg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654371999; a=rsa-sha256; cv=none; b=Le+bWpe2PKY2U7U2HSozsCpBeshlNG1klXUqklloMnQvtkq/HOb/X6iugp4FyF/2Pj4k3H GSTNWWP0oRlblZ8DXIFd08pOHJ21+Ppm5gXlukVGgUWkqbtkkaS1u5fh/GhK/LHJ2Guvjz Ejr3yNnwAc7dIVZp0JhiV/5z331LAY/TN3a3iDVLHobJewh0RwtfPyvYRCgsJDFvCYE9y7 A1zkBdA2V3deRlmoRXgNW4xuxOlk8jeI9DWgF7kRVW0rTvO6vNZnjarcPkifXPm3ZTLQMK vO2w4OQulDZk4b3sM2KOReI3tMgfSVmU9zCuJtfsHUhwra8MZZWJjKlPvx7aXg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=kDM3Oomc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gnu.org (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 7.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=kDM3Oomc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gnu.org (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 4B2E78DBC X-Spam-Score: 7.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: PKAKdLI3RkWJ notmuch-mua functions for replies now use the built-in customizable variable message-dont-reply-to-names with the same semantics as message-mode. Signed-off-by: jao --- doc/notmuch-emacs.rst | 9 ++++++++ emacs/notmuch-mua.el | 13 ++++++++++++ test/T454-emacs-dont-reply-names.sh | 33 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100755 test/T454-emacs-dont-reply-names.sh diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index 78528785..970cd7b7 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -493,6 +493,15 @@ Sending Mail :code:`compose-mail`. To use ``notmuch`` for this, customize this variable to the symbol :code:`notmuch-user-agent`. +:index:`message-dont-reply-to-names` + + When composing mail replies, Emacs's message mode uses the + variable :code:`message-dont-reply-to-names` to exclude + recipients matching a given collection of regular expressions + or satisfying an arbitrary predicate. Notmuch's MUA inherits + this standard mechanism and will honour your customization of + this variable. + Init File --------- diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 0ae33127..6f2b9789 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -382,6 +382,18 @@ instead of `message-mode' and SWITCH-FUNCTION is mandatory." (erase-buffer) (notmuch-message-mode))) +(defun notmuch-mua--remove-dont-reply-to-names () + (when-let ((nr (message-dont-reply-to-names))) + (let ((nr-filter (if (functionp nr) + nr + (lambda (mail) (unless (string-match-p nr mail) mail))))) + (dolist (header '("To" "Cc")) + (when-let ((v (message-fetch-field header))) + (let* ((v (message-tokenize-header v)) + (vs (delq nil (mapcar nr-filter v))) + (v (when vs (mapconcat #'string-trim vs ", ")))) + (message-replace-header header v))))))) + (defun notmuch-mua-mail (&optional to subject other-headers _continue switch-function yank-action send-actions return-action &rest ignored) @@ -422,6 +434,7 @@ moved to the \"To:\" header." (message-this-is-mail t)) (message-setup-1 headers yank-action send-actions return-action)) (notmuch-fcc-header-setup) + (notmuch-mua--remove-dont-reply-to-names) (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) diff --git a/test/T454-emacs-dont-reply-names.sh b/test/T454-emacs-dont-reply-names.sh new file mode 100755 index 00000000..64ae74af --- /dev/null +++ b/test/T454-emacs-dont-reply-names.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +test_description="emacs reply" +. $(dirname "$0")/test-lib.sh || exit 1 +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1 + +EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output + +test_require_emacs + +add_email_corpus default + +test_begin_subtest "not replying" +test_emacs '(let ((message-dont-reply-to-names "notmuchmail\\|noreply\\|harvard")) + (notmuch-mua-new-reply + "id:20091117203301.GV3165@dottiness.seas.harvard.edu" nil t) + (test-visible-output "OUTPUT-FULL.raw"))' + +notmuch_dir_sanitize < OUTPUT-FULL.raw > OUTPUT-FULL +head -6 OUTPUT-FULL > OUTPUT + +cat < EXPECTED +From: Notmuch Test Suite +To: Mikhail Gusarov +Subject: Re: [notmuch] Working with Maildir storage? +In-Reply-To: <20091117203301.GV3165@dottiness.seas.harvard.edu> +Fcc: MAIL_DIR/sent +--text follows this line-- +EOF + +test_expect_equal_file EXPECTED OUTPUT + +test_done -- 2.36.1