mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 03:48:10 +01:00
emacs: use message-dont-reply-to-names when composing replies
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 commit is contained in:
parent
fb4a0967ca
commit
9695e4c38d
3 changed files with 104 additions and 0 deletions
|
@ -493,6 +493,15 @@ Sending Mail
|
||||||
:code:`compose-mail`. To use ``notmuch`` for this, customize this
|
:code:`compose-mail`. To use ``notmuch`` for this, customize this
|
||||||
variable to the symbol :code:`notmuch-user-agent`.
|
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
|
Init File
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(eval-when-compile (require 'subr-x))
|
||||||
|
|
||||||
(require 'message)
|
(require 'message)
|
||||||
|
(require 'gmm-utils)
|
||||||
(require 'mm-view)
|
(require 'mm-view)
|
||||||
(require 'format-spec)
|
(require 'format-spec)
|
||||||
|
|
||||||
|
@ -382,6 +385,21 @@ instead of `message-mode' and SWITCH-FUNCTION is mandatory."
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(notmuch-message-mode)))
|
(notmuch-message-mode)))
|
||||||
|
|
||||||
|
(defun notmuch-mua--remove-dont-reply-to-names ()
|
||||||
|
(when-let* ((nr (if (functionp message-dont-reply-to-names)
|
||||||
|
message-dont-reply-to-names
|
||||||
|
(gmm-regexp-concat message-dont-reply-to-names)))
|
||||||
|
(nr-filter
|
||||||
|
(if (functionp nr)
|
||||||
|
(lambda (mail) (and (not (funcall nr mail)) mail))
|
||||||
|
(lambda (mail) (and (not (string-match-p nr mail)) mail)))))
|
||||||
|
(dolist (header '("To" "Cc"))
|
||||||
|
(when-let ((v (message-fetch-field header)))
|
||||||
|
(let* ((tokens (mapcar #'string-trim (message-tokenize-header v)))
|
||||||
|
(good-tokens (delq nil (mapcar nr-filter tokens)))
|
||||||
|
(addr (and good-tokens (mapconcat #'identity good-tokens ", "))))
|
||||||
|
(message-replace-header header addr))))))
|
||||||
|
|
||||||
(defun notmuch-mua-mail (&optional to subject other-headers _continue
|
(defun notmuch-mua-mail (&optional to subject other-headers _continue
|
||||||
switch-function yank-action send-actions
|
switch-function yank-action send-actions
|
||||||
return-action &rest ignored)
|
return-action &rest ignored)
|
||||||
|
@ -422,6 +440,7 @@ moved to the \"To:\" header."
|
||||||
(message-this-is-mail t))
|
(message-this-is-mail t))
|
||||||
(message-setup-1 headers yank-action send-actions return-action))
|
(message-setup-1 headers yank-action send-actions return-action))
|
||||||
(notmuch-fcc-header-setup)
|
(notmuch-fcc-header-setup)
|
||||||
|
(notmuch-mua--remove-dont-reply-to-names)
|
||||||
(message-sort-headers)
|
(message-sort-headers)
|
||||||
(message-hide-headers)
|
(message-hide-headers)
|
||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
|
|
76
test/T454-emacs-dont-reply-names.sh
Executable file
76
test/T454-emacs-dont-reply-names.sh
Executable file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
test_description="message-dont-reply-to-names in emacs replies"
|
||||||
|
. $(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 <<EOF > EXPECTED
|
||||||
|
From: Notmuch Test Suite <test_suite@notmuchmail.org>
|
||||||
|
To: Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||||
|
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 <<EOF > EXPECTED-PRED
|
||||||
|
From: Notmuch Test Suite <test_suite@notmuchmail.org>
|
||||||
|
To: Lars Kellogg-Stedman <lars@seas.harvard.edu>
|
||||||
|
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 <<EOF > EXPECTED-NIL
|
||||||
|
From: Notmuch Test Suite <test_suite@notmuchmail.org>
|
||||||
|
To: Lars Kellogg-Stedman <lars@seas.harvard.edu>, Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||||
|
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
|
Loading…
Reference in a new issue