unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: Charlie Allom <charlie@yelp.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH v3] Allow content preference based on message content.
Date: Sat, 30 Jul 2016 15:12:09 +0100	[thread overview]
Message-ID: <m21t2bb4g6.fsf@dme.org> (raw)
In-Reply-To: <m1oa5fuv9v.fsf@YELP-CHARLIE.i-did-not-set--mail-host-address--so-tickle-me>

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@capita-intouch.co.uk"
			 ;; Oracle mobile reports: text/plain with useless content.
			 "TEMA Alerts"
			 ;; Charles Stanley: HTML only emails.
			 "info@charles-stanley-direct.co.uk"
			 ;; HackerNews: nicer in HTML.
			 "kale@hackernewsletter.com"
			 ;; MasterCard: no content in the text.
			 "CustomerService@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@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@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@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(-)
>
> -- 

      parent reply	other threads:[~2016-07-30 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-03 16:04 [PATCH v3] Allow content preference based on message content David Edmondson
2016-04-03 16:04 ` [PATCH v3] emacs: Allow part preferences to depend " David Edmondson
2016-04-09 19:19   ` David Bremner
     [not found] ` <m1oa5fuv9v.fsf@YELP-CHARLIE.i-did-not-set--mail-host-address--so-tickle-me>
2016-07-30 14:12   ` David Edmondson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21t2bb4g6.fsf@dme.org \
    --to=dme@dme.org \
    --cc=charlie@yelp.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).