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 0OWTC+BJoWJiUwAAbAwnHQ (envelope-from ) for ; Thu, 09 Jun 2022 03:16:16 +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 OCl/C+BJoWKVHQEA9RJhRA (envelope-from ) for ; Thu, 09 Jun 2022 03:16:16 +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 B366B11E30 for ; Thu, 9 Jun 2022 03:16:15 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CB5275F767; Thu, 9 Jun 2022 01:16:12 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id DFCAA5F748 for ; Thu, 9 Jun 2022 01:16:09 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 786395FBD7; Wed, 8 Jun 2022 21:16:08 -0400 (EDT) Received: (nullmailer pid 2696639 invoked by uid 1000); Thu, 09 Jun 2022 01:16:06 -0000 From: David Bremner To: jao , notmuch@notmuchmail.org Subject: Re: [PATCH v2] emacs: use message-dont-reply-to-names when composing replies In-Reply-To: <20220604202127.2379152-1-jao@gnu.org> References: <20220604202127.2379152-1-jao@gnu.org> Date: Wed, 08 Jun 2022 22:16:06 -0300 Message-ID: <8735ge1vs9.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: BRMV4VJQSWTZSP7ZSLGL2PH2OVGMGT3H X-Message-ID-Hash: BRMV4VJQSWTZSP7ZSLGL2PH2OVGMGT3H X-MailFrom: david@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 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=1654737375; 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-owner:list-unsubscribe:list-subscribe:list-post; bh=hqadfkd12RQRhFS23rGhEsuxccrR7ByQYNSmJpeYl+0=; b=kTBa2xJsO6nCCeOmm95REhPOIcSArL+FGGHFeSt4HiirUvGe/2A5pb0QWenhwjkVEN25YB BaMpjcJ8xrjucovzW0aROxpb8zvm0eWZ5O7Qc1F7qmGd/JX37uaObUK5+jzbWHfdjnVOCZ 6CkE9sWrcjg6cxVdmd1itJtHi5Zu9edclaLo6NQ2lpvi2VHNRP0DvMH/K0bxGAnMv/qcR4 j804quHesoI2jpOY2URZkKhxqWX6bsx5ajRcs7AOi8yjEKip88TR7/nyCBVB/1ZYUBSdCn D0XXuhMw70i8IvrSdSv0DFxLOnqyB+2I1c2pbAXeCXJAHqOpAf/K9p13Ye22/g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654737375; a=rsa-sha256; cv=none; b=ggrwAtWiiRj/W7FiZzTsSkAPoLpnZP1d8QzDcb2s6MtaWxAqmQgkbbhSorSufDaFtoCfeA 66rKvYPhK/9iYQmQrt+6QiQ8qXRijAe1MAKc1i8yJnuKNhBZfdvT6+kv30U2bSMfF3mage KGy/DBa+vRh97cNsIzHnFLmFUh550YglHNkalkOx2Edc+KM0saSimR97/p3l9Ko/S6d1vw BFYb3fCTeVcxGiiGnipol9SLtWeBv9CigKJSnitH39606meeaOsPNeHjpYTgtj1bTVBGpw CbYmCR3atR/L0LSajh8+iMUO+6sA8jX/K2efLgRc129iHRdt6yFRJ2GtJh50VA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=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: -2.10 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=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: B366B11E30 X-Spam-Score: -2.10 X-Migadu-Scanner: scn1.migadu.com X-TUID: pJLYDm6U54kn jao writes: > > > +(defun notmuch-mua--remove-dont-reply-to-names () > + (when-let ((nr (message-dont-reply-to-names))) Using when-let is fine with me, but I wonder if we should follow the advice in subr-x to do (eval-when-compile (require 'subr-x)) It's autoloaded, but maybe we can improve loading time a little? I noticed the other places we just do (require 'subr-x), but we're not always the most *cough* sophisticated elisp programmers. I'm a bit nervous about calling an undocumented defsubst here. It might be better to inline the 3 line definition. What do you think? > + (let ((nr-filter (if (functionp nr) > + (lambda (mail) (unless (funcall nr mail) mail)) > + (lambda (mail) (unless (string-match-p nr mail) mail))))) Inlining the definition would also make it more clear that the above code handles the case where message-dont-reply-to-names is list of regexps. Failing that maybe a comment. > + (dolist (header '("To" "Cc")) I found the re-use of v confusing in this 'when-let'. It reminds me of an exam question about scope :). > + (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 ", ")))) I think 'and' is conventional for places where we care about what the expression evaluates to, and 'when' preferred when not. > + (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" I guess this description should match the name of the file and mention something like "don't reply"; this will make the individual test descriptions make more sense > +. $(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"))' > + Maybe mention this tests Cc; I don't _think_ the other tests do?