[PATCH v3] Allow content preference based on message content.

David Edmondson dme at dme.org
Sat Jul 30 07:12:09 PDT 2016


On Sat, Jul 30 2016, Charlie Allom wrote:

> Do you have an example for the elisp-challenged, on how to match more
> than one email address? I'm just starting out with emacs but this patch
> is just what I need :)

There are many ways. This is what I am using:

  (defun dme:determine-discouraged (msg)
    (let* ((headers (plist-get msg :headers))
	   (from (or (plist-get headers :From) "")))
      (cond
       ((string-match (regexp-opt
		       '(
			 ;; Parmiter's parent mail: text/plain with HTML content.
			 "9195404 at capita-intouch.co.uk"
			 ;; Oracle mobile reports: text/plain with useless content.
			 "TEMA Alerts"
			 ;; Charles Stanley: HTML only emails.
			 "info at charles-stanley-direct.co.uk"
			 ;; HackerNews: nicer in HTML.
			 "kale at hackernewsletter.com"
			 ;; MasterCard: no content in the text.
			 "CustomerService at information.mbna.co.uk"
			 ))
		      from)
	'("text/plain"))
       (t
	'("text/html" "multipart/related" "text/x-beehive-notification")))))


> Regards,
>   Charlie.
>   
> On Sun, Apr 03 2016 at 05:04:37 pm, David Edmondson <dme at dme.org> wrote:
>
>> Allow content preference based on message content.
>>
>> An example configuration might be:
>>
>>   (defun dme:determine-discouraged (msg)
>>     (let* ((headers (plist-get msg :headers))
>> 	   (from (or (plist-get headers :From) "")))
>>       (cond
>>        ((string-match "9195404 at capita-intouch.co.uk" from)
>> 	'("text/plain"))
>>        (t
>> 	'("text/html" "multipart/related")))))
>>
>>   (setq notmuch-multipart/alternative-discouraged
>>   	'dme:determine-discouraged)
>>
>> This would discourage text/html and multipart/related generally, but
>> discourage text/plain should the message be sent from
>> 9195404 at capita-intouch.co.uk.
>>
>> v2:
>> - Remove the simple evaluation variant based on feedback.
>>
>> v3:
>> - Merge forward.
>> - Update the example to allow for a nil msg (which should no longer
>>   happen, but it's good to be safe).
>>
>>
>> David Edmondson (1):
>>   emacs: Allow part preferences to depend on message content.
>>
>>  emacs/notmuch-lib.el  | 20 ++++++++++++++++----
>>  emacs/notmuch-show.el |  2 +-
>>  2 files changed, 17 insertions(+), 5 deletions(-)
>
> -- 


More information about the notmuch mailing list