[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9978e88: Remove repetitions from recipient addresse
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 9978e88: Remove repetitions from recipient addresses in Message |
Date: |
Thu, 12 Apr 2018 09:00:19 -0400 (EDT) |
branch: master
commit 9978e88b31a59510a6d24b3ff740172700479f11
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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 "address@hidden" <address@hidden>.
---
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 6701671..e3f05f3 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
+'"address@hidden" <address@hidden>', 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 b979e1c..7079cc7 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 \"\"address@hidden"\" <address@hidden>\".
+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 a955597..27b8c10 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 <address@hidden>")
+ "Lars Ingebrigtsen <address@hidden>"))
+
+ (should (equal (message--alter-repeat-address
+ "\"address@hidden" <address@hidden>")
+ "address@hidden")))
+
(provide 'message-mode-tests)
;;; message-mode-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9978e88: Remove repetitions from recipient addresses in Message,
Lars Ingebrigtsen <=