From 9978e88b31a59510a6d24b3ff740172700479f11 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 12 Apr 2018 14:57:51 +0200 Subject: [PATCH] Remove repetitions from recipient addresses in Message * lisp/gnus/message.el (message--alter-repeat-address): New function. (message-get-reply-headers): Use it to remove repetitions on the form "foo@bar.com" . --- etc/NEWS | 5 +++++ lisp/gnus/message.el | 12 ++++++++++++ test/lisp/gnus/message-tests.el | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 670167165af..e3f05f3e0f5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -361,6 +361,11 @@ when the PGP keyring contains a public key for every recipient. To achieve this, add 'message-sign-encrypt-if-all-keys-available' to 'message-send-hook'. +--- +*** When replying a message that have addresses on the form +'"foo@bar.com" ', Message will elide the repeated "name" +from the address field in the response. + * New Modes and Packages in Emacs 27.1 +++ diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index b979e1c5044..7079cc73e1f 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -6867,6 +6867,9 @@ want to get rid of this query permanently."))) (setq recipients (delq recip recipients)))))))) (setq recipients (message-prune-recipients recipients)) + (setq recipients + (cl-loop for (id . address) in recipients + collect (cons id (message--alter-repeat-address address)))) ;; Build the header alist. Allow the user to be asked whether ;; or not to reply to all recipients in a wide reply. @@ -6897,6 +6900,15 @@ want to get rid of this query permanently."))) (setq recipients (delq recipient recipients)))))))) recipients) +(defun message--alter-repeat-address (address) + "Transform an address on the form \"\"foo@bar.com\"\" \". +The first bit will be elided if a match is made." + (let ((bits (gnus-extract-address-components address))) + (if (equal (car bits) (cadr bits)) + (car bits) + ;; Return the original address if we don't have repetition. + address))) + (defcustom message-simplify-subject-functions '(message-strip-list-identifiers message-strip-subject-re diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el index a95559775b6..27b8c10dc03 100644 --- a/test/lisp/gnus/message-tests.el +++ b/test/lisp/gnus/message-tests.el @@ -145,6 +145,15 @@ (setq recipients (list person1 person2 person3)) (should-not (message-all-epg-keys-available-p))))) +(ert-deftest message-alter-repeat-address () + (should (equal (message--alter-repeat-address + "Lars Ingebrigtsen ") + "Lars Ingebrigtsen ")) + + (should (equal (message--alter-repeat-address + "\"larsi@gnus.org\" ") + "larsi@gnus.org"))) + (provide 'message-mode-tests) ;;; message-mode-tests.el ends here -- 2.39.5