It would be cool to be able to alter the address before it is inserted into the mail buffer. For instance, I don't like to insert names with email addresses. So I want to send messages to john@mailserver.org rather than John W <john@mailserver.org>. On replies I can use message-alter-recipients-function, but this is run 'too early' to work on addresses inserted with gnus-harvest.
The following is a very simple patch that allows one to run a custom function on addresses before insertion. Perhaps it should follow message-alter-recipients-function but this would require more work. I can look into it, if that's desired.
From 593be034904feebec23d67cd7602a8bc39a1c4b9 Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@gmx.us>
Date: Fri, 4 Oct 2013 17:26:57 +0200
Subject: [PATCH] Allow function call on address before insertion
---
gnus-harvest.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gnus-harvest.el b/gnus-harvest.el
index 4b72cd9..d57cfc2 100644
--- a/gnus-harvest.el
+++ b/gnus-harvest.el
@@ -107,6 +107,13 @@ to something else.
:type '(alist :key-type regexp :value_type string)
:group 'gnus-harvest)
+(defcustom gnus-harvest-address-function nil
+ "A function applied to the address string just before insertion.
+
+For example, if you only want to insert the email address of
+contacts set this variable to mail-strip-quoted-names.")
+
+
(defun gnus-harvest-set-from (&optional address)
(unless (message-field-value "from")
(let ((to (message-field-value "to")))
@@ -336,7 +343,8 @@ VALUES
(t
(insert stub)
(error "Could not find any matches for '%s'" stub))))))
- (insert addr)
+ (insert (if gnus-harvest-address-function
+ (funcall gnus-harvest-address-function addr) addr))
(if text-follows
(insert ", "))
(gnus-harvest-set-from (and addrs (cdr (assoc addr addrs))))
--
1.8.4
Hi,
It would be cool to be able to alter the address before it is inserted into the mail buffer. For instance, I don't like to insert names with email addresses. So I want to send messages to
john@mailserver.org
rather thanJohn W <john@mailserver.org>
. On replies I can usemessage-alter-recipients-function
, but this is run 'too early' to work on addresses inserted withgnus-harvest
.The following is a very simple patch that allows one to run a custom function on addresses before insertion. Perhaps it should follow
message-alter-recipients-function
but this would require more work. I can look into it, if that's desired.