>From 208004b00ea4c063d653e6e495ee8c4b2c8f3b51 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sat, 23 May 2015 15:42:28 +0200 Subject: [PATCH 3/3] Allow message-dont-reply-to-names to be a function --- GNUS-NEWS | 2 ++ lisp/ChangeLog | 6 ++++++ lisp/message.el | 28 ++++++++++++++++++++++------ texi/message.texi | 5 +++-- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/GNUS-NEWS b/GNUS-NEWS index dce7eda..2c29a75 100644 --- a/GNUS-NEWS +++ b/GNUS-NEWS @@ -9,6 +9,8 @@ For older news, see Gnus info node "New Features". * New features +** message-dont-reply-to-names can take a function as a value. + ** gnus-ignored-from-addresses can take a function as a value. ** message-alternative-emails can take a function as a value. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c72bd64..e0e7dea 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -14,6 +14,12 @@ 2015-05-23 Rasmus Pank Roulund + * message.el (message-dont-reply-to-names): Allow function as value. + (message-dont-reply-to-names, message-get-reply-headers): Allow + function value for `message-dont-reply-to-names'. + +2015-05-23 Rasmus Pank Roulund + * gnus-sum.el (gnus-ignored-from-addresses): Allow function as value. * gnus-notifications.el (gnus-notifications): * gnus-icalendar.el (gnus-icalendar-identities): diff --git a/lisp/message.el b/lisp/message.el index d219a41..000ef70 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -1398,8 +1398,10 @@ If nil, you might be asked to input the charset." (defcustom message-dont-reply-to-names (and (boundp 'mail-dont-reply-to-names) mail-dont-reply-to-names) "*Addresses to prune when doing wide replies. -This can be a regexp or a list of regexps. Also, a value of nil means -exclude your own user name only." +This can be a regexp, a list of regexps or a predicate function. +Also, a value of nil means exclude your own user name only. + +If a function email is passed as the argument." :version "24.3" :group 'message :link '(custom-manual "(message)Wide Reply") @@ -1408,7 +1410,10 @@ exclude your own user name only." (repeat :tag "Regexp List" regexp))) (defsubst message-dont-reply-to-names () - (gmm-regexp-concat message-dont-reply-to-names)) + (cond ((functionp message-dont-reply-to-names) + message-dont-reply-to-names) + ((stringp message-dont-reply-to-names) + (gmm-regexp-concat message-dont-reply-to-names)))) (defvar message-shoot-gnksa-feet nil "*A list of GNKSA feet you are allowed to shoot. @@ -6967,9 +6972,20 @@ want to get rid of this query permanently."))) ;; Squeeze whitespace. (while (string-match "[ \t][ \t]+" recipients) (setq recipients (replace-match " " t t recipients))) - ;; Remove addresses that match `mail-dont-reply-to-names'. - (let ((mail-dont-reply-to-names (message-dont-reply-to-names))) - (setq recipients (mail-dont-reply-to recipients))) + ;; Remove addresses that match `message-dont-reply-to-names'. + (setq recipients + (cond ((functionp message-dont-reply-to-names) + (mapconcat + 'identity + (delq nil + (mapcar (lambda (mail) + (unless (funcall message-dont-reply-to-names + (mail-strip-quoted-names mail)) + mail)) + (message-tokenize-header recipients))) + ", ")) + (t (let ((mail-dont-reply-to-names (message-dont-reply-to-names))) + (mail-dont-reply-to recipients))))) ;; Perhaps "Mail-Copies-To: never" removed the only address? (if (string-equal recipients "") (setq recipients author)) diff --git a/texi/message.texi b/texi/message.texi index 1b18a04..2e7fee0 100644 --- a/texi/message.texi +++ b/texi/message.texi @@ -185,8 +185,9 @@ but you can change the behavior to suit your needs by fiddling with the @vindex message-dont-reply-to-names Addresses that match the @code{message-dont-reply-to-names} regular -expression (or list of regular expressions) will be removed from the -@code{Cc} header. A value of @code{nil} means exclude your name only. +expression (or list of regular expressions or a predicate function) +will be removed from the @code{Cc} header. A value of @code{nil} means +exclude your name only. @vindex message-prune-recipient-rules @code{message-prune-recipient-rules} is used to prune the addresses -- 2.4.1