1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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" <foo@bar.com>.
This commit is contained in:
Lars Ingebrigtsen 2018-04-12 14:57:51 +02:00
parent 20c6a516ec
commit 9978e88b31
3 changed files with 26 additions and 0 deletions

View file

@ -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" <foo@bar.com>', Message will elide the repeated "name"
from the address field in the response.
* New Modes and Packages in Emacs 27.1
+++

View file

@ -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\"\" <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

View file

@ -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 <larsi@gnus.org>")
"Lars Ingebrigtsen <larsi@gnus.org>"))
(should (equal (message--alter-repeat-address
"\"larsi@gnus.org\" <larsi@gnus.org>")
"larsi@gnus.org")))
(provide 'message-mode-tests)
;;; message-mode-tests.el ends here