From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 eE+FMNi+m2KzRwAAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 22:21:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CAeiMNi+m2LMgQAA9RJhRA (envelope-from ) for ; Sat, 04 Jun 2022 22:21:44 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 78C879A41 for ; Sat, 4 Jun 2022 22:21:44 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id F00575F7C5; Sat, 4 Jun 2022 20:21:41 +0000 (UTC) Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by mail.notmuchmail.org (Postfix) with ESMTPS id D63A45F7B9 for ; Sat, 4 Jun 2022 20:21:39 +0000 (UTC) Received: from fencepost.gnu.org ([2001:470:142:3::e]:59276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxaHB-0000Nr-Rw; Sat, 04 Jun 2022 16:21:37 -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=Ql75p80VL2ciiuFdeeeNi/i2DQlFJlV6mawA9EiMLUc=; b=ctGfNipgZucjbc fdX+BtpXh0fOfVm52iefOsLJw7nGetdXBBhqTWHCFows44I8q5yE9LjEay1xEZPINFEVyx9wZBZjA Y1hZPSTEtnPqA8gEXdbdZZSigso+Z/x9Q6dJhITXDtjhEWSI3EEXCqA5iq4WpzGRM7D2Aw0OV/CcR rI40ehTQyfDziBifVIXli/pZW/em0DHpjPaXhyljLa1r0SYntksPhOMH2Y9XGeiw3v/Y3oXIDX6LH wrrmWpLcuQ/7IvjTLQYh2LRtp5MvyLr8pDVwKbctEBnlZm1mwUWhp8cePj9ZGU52bTOc9zKQz+Y2J z7T2iTiAj2W6CkkIjIqA==; Received: from [92.233.85.247] (port=50580 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 1nxaHB-0006Qi-Eg; Sat, 04 Jun 2022 16:21:37 -0400 From: jao To: notmuch@notmuchmail.org Subject: [PATCH v2] emacs: use message-dont-reply-to-names when composing replies Date: Sat, 4 Jun 2022 21:21:27 +0100 Message-Id: <20220604202127.2379152-1-jao@gnu.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Message-ID-Hash: 75JIVKZIEA7HEEKN3PRPX6F2S3UYK53M X-Message-ID-Hash: 75JIVKZIEA7HEEKN3PRPX6F2S3UYK53M 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=1654374104; 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=5zXMK5p2QcjkVKtqOWswLLWLm1KZUHiuV5vTfl62YXg=; b=Pf0e4roZdIObPTZXijbWqvlwKoyBBzQzxr015Nr6dlIsf+p7hRazssXwEEVm/UV1z6+ihl RzEsvjMQM69puqU1S4vWZeyDjkJ8LPuq7Mjr0UbAyrNfW6/YQI5s7vuNbFE1Z8QKdZn3/9 O89Uc2XYs6rN8pd6l9e6R7xtk5HTTT04HBaSxH3wi9o6PeZ/25nmrFmtOX1Jy8JSi+Dwn6 PBXzZLErQewc24xQXqWW4e0y7xQH4M1C3oc5MUdLKBp9WC96/l23Dj+4MWzz60mzXtjadD CXQEaJJgAR2aRtl2lSrdJxVhnu89v7TTz6OR/SI4jmXqmR2VdWUDqc7WJJJdzQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654374104; a=rsa-sha256; cv=none; b=HfPi6LIH5JFqAOLxaSBGHUG4e88KCZHtjTxXfEy9inNVVblFnURDsOcVQdxfXCvhvWM2j/ ++vP0nrU1G1IJFREaOYyL5/33ArbBRYQavB2dBfXbXty++v3mpdrKZhGwXn77Mo7XwZ5sR RbwO79m2j6whnvha0b0Mf3CdkmzcrHhPvcyeKcsIZofUnPTA2cNIO+95AmOD959vYXfjIX SN4HDATCF43FpYOo6KfPH0tFoTW2xW3orYGWMOW/Er9IYewX9kbrCU5tQIhfxhbCRih3O7 ReQOIsjvxEVe54mXa3axcJfqHJxgCep5aOT7z585llG7dPUVOeO1Heiv9Geqmg== 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=ctGfNipg; 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 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 6.75 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=ctGfNipg; 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 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 78C879A41 X-Spam-Score: 6.75 X-Migadu-Scanner: scn0.migadu.com X-TUID: lWYDAXalYWgi notmuch-mua functions for replies now use the built-in customizable variable message-dont-reply-to-names with the same semantics as message-mode. --- This version of the patch adds more testing and ensures predicate values work Signed-off-by: jao --- doc/notmuch-emacs.rst | 9 ++++ emacs/notmuch-mua.el | 13 +++++ test/T454-emacs-dont-reply-names.sh | 76 +++++++++++++++++++++++++++++ 3 files changed, 98 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..865f4bb2 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) + (lambda (mail) (unless (funcall nr mail) mail)) + (lambda (mail) (unless (string-match-p nr mail) mail))))) + (dolist (header '("To" "Cc")) + (when-let ((v (message-fetch-field header))) + (let* ((v (mapcar #'string-trim (message-tokenize-header v))) + (vs (delq nil (mapcar nr-filter v))) + (v (when vs (mapconcat #'identity 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..e31141f9 --- /dev/null +++ b/test/T454-emacs-dont-reply-names.sh @@ -0,0 +1,76 @@ +#!/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 "regular expression" +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_begin_subtest "predicate" +test_emacs '(let ((message-dont-reply-to-names + (lambda (m) (string-prefix-p "Mikhail" m)))) + (notmuch-mua-new-reply + "id:20091117203301.GV3165@dottiness.seas.harvard.edu" nil t) + (test-visible-output "OUTPUT-FULL-PRED.raw"))' + +notmuch_dir_sanitize < OUTPUT-FULL-PRED.raw > OUTPUT-FULL-PRED +head -7 OUTPUT-FULL-PRED > OUTPUT-PRED + +cat < EXPECTED-PRED +From: Notmuch Test Suite +To: Lars Kellogg-Stedman +Cc: notmuch@notmuchmail.org +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-PRED OUTPUT-PRED + +test_begin_subtest "nil value" +test_emacs '(let ((message-dont-reply-to-names nil)) + (notmuch-mua-new-reply + "id:20091117203301.GV3165@dottiness.seas.harvard.edu" nil t) + (test-visible-output "OUTPUT-FULL-NIL.raw"))' + +notmuch_dir_sanitize < OUTPUT-FULL-NIL.raw > OUTPUT-FULL-NIL +head -7 OUTPUT-FULL-NIL > OUTPUT-NIL + +cat < EXPECTED-NIL +From: Notmuch Test Suite +To: Lars Kellogg-Stedman , Mikhail Gusarov +Cc: notmuch@notmuchmail.org +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-NIL OUTPUT-NIL + +test_done -- 2.36.1