From 7333882cabe0c44bdab41b9623bebdbd43f1bbac Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Sat, 30 Jul 2016 15:12:09 +0100 Subject: [PATCH] Re: [PATCH v3] Allow content preference based on message content. --- c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 | 155 ++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 diff --git a/c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 b/c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 new file mode 100644 index 000000000..95f346554 --- /dev/null +++ b/c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 @@ -0,0 +1,155 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 61D046DE0159 + for ; Sat, 30 Jul 2016 07:12:22 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.191 +X-Spam-Level: +X-Spam-Status: No, score=-0.191 tagged_above=-999 required=5 + tests=[AWL=-0.124, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id FHo9EhcE9kLc for ; + Sat, 30 Jul 2016 07:12:14 -0700 (PDT) +Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com + [74.125.82.52]) by arlo.cworth.org (Postfix) with ESMTPS id CA8326DE00F5 for + ; Sat, 30 Jul 2016 07:12:13 -0700 (PDT) +Received: by mail-wm0-f52.google.com with SMTP id f65so320280541wmi.0 + for ; Sat, 30 Jul 2016 07:12:13 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=dme-org.20150623.gappssmtp.com; s=20150623; + h=to:subject:in-reply-to:references:from:date:message-id:mime-version; + bh=OBBsQTs5Gd5Z/5UbLlhX8sWSiDWjUhdTG+wCDm9JH8g=; + b=pp9c1HJZQ4J5fdTUy5hNfU0qQueFVk+2pjd/E3lcRvlZ7S3hoSIe3UX/seZNADRG8+ + XG0t4Owwf2gAXfO8v8WZbJPXBlvRgtZt/GQx9dxWCpP/NryxLpeSWUdsRM8kxbsZTtVl + kzn/SeBH1yXa/FnPC/HyeTZ+jlrtSGXFbF/UjdOIXt9BP92rTahiIAzhBOypbxNcjSpL + VPlOsA36ayWJq2UrHkqxShnMSgPk1GDyxyZlEp+dCVELqf0ZfX6Vbxo7rbf+f3ozu0oC + hAwd5BDeGgitMxFkw51tbkTJdCvPaDwI9Oy8uxyPuvz4fg8dOwsSLxANktKqkDcMA71Y + 4VMw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:to:subject:in-reply-to:references:from:date + :message-id:mime-version; + bh=OBBsQTs5Gd5Z/5UbLlhX8sWSiDWjUhdTG+wCDm9JH8g=; + b=dlgNSHgwx4R5WOVFJRhHsVvvI8F/XJEWWCdHm96VIm3XhdxsnrDVxIh6mUSGD0wj5c + Zo68dcXGW3JyJ33yNW9U7/fORUbeQtOFLa4TYKJcOtfij9O/zG08zvG9n2trnvOdRwKD + 3dHFAXc8tc6kE9VpAZDOBsgLZ2jKbSzHclvOsFJK1fuIEC/CgG2Tvtczeg7JH2Vv0EYk + OF2Dfcigfh3t+M75gnnVutmVhjnxjGt/vrH/qIBNkr7SJ8wu01TtSYF8zp/FjJ1kxQo5 + /JzzmVRhwJnfFuS4zevvpLLjL6yB4JUQa/qGuH0hpydon/bnTzR8FIkkapObdKx4J6PA + vNVQ== +X-Gm-Message-State: + AEkoouu8DhVHhdRyGp1l1ONOEDPn8GnDKT5ShdU4IraUciTGSPM1CabM0Qdo15s3+HdXxA== +X-Received: by 10.28.50.3 with SMTP id y3mr42351656wmy.23.1469887932116; + Sat, 30 Jul 2016 07:12:12 -0700 (PDT) +Received: from disaster-area.hh.sledj.net + ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) + by smtp.gmail.com with ESMTPSA id n7sm21470579wjf.11.2016.07.30.07.12.10 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 30 Jul 2016 07:12:10 -0700 (PDT) +Received: from localhost (disaster-area.hh.sledj.net [local]) + by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 69c63fc6; + Sat, 30 Jul 2016 14:12:09 +0000 (UTC) +To: Charlie Allom , notmuch@notmuchmail.org +Subject: Re: [PATCH v3] Allow content preference based on message content. +In-Reply-To: + +References: <1459699478-21167-1-git-send-email-dme@dme.org> + +From: David Edmondson +Date: Sat, 30 Jul 2016 15:12:09 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 30 Jul 2016 14:12:22 -0000 + +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 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(-) +> +> -- -- 2.26.2