Re: [PATCH v3] Allow content preference based on message content.
authorDavid Edmondson <dme@dme.org>
Sat, 30 Jul 2016 14:12:09 +0000 (15:12 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:16 +0000 (16:22 -0700)
c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 [new file with mode: 0644]

diff --git a/c8/0c76d4a129addb6dbf5686cecd0be7013ecf21 b/c8/0c76d4a129addb6dbf5686cecd0be7013ecf21
new file mode 100644 (file)
index 0000000..95f3465
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 61D046DE0159\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Jul 2016 07:12:22 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.191\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.191 tagged_above=-999 required=5\r
+ tests=[AWL=-0.124, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id FHo9EhcE9kLc for <notmuch@notmuchmail.org>;\r
+ Sat, 30 Jul 2016 07:12:14 -0700 (PDT)\r
+Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com\r
+ [74.125.82.52]) by arlo.cworth.org (Postfix) with ESMTPS id CA8326DE00F5 for\r
+ <notmuch@notmuchmail.org>; Sat, 30 Jul 2016 07:12:13 -0700 (PDT)\r
+Received: by mail-wm0-f52.google.com with SMTP id f65so320280541wmi.0\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Jul 2016 07:12:13 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=dme-org.20150623.gappssmtp.com; s=20150623;\r
+ h=to:subject:in-reply-to:references:from:date:message-id:mime-version;\r
+ bh=OBBsQTs5Gd5Z/5UbLlhX8sWSiDWjUhdTG+wCDm9JH8g=;\r
+ b=pp9c1HJZQ4J5fdTUy5hNfU0qQueFVk+2pjd/E3lcRvlZ7S3hoSIe3UX/seZNADRG8+\r
+ XG0t4Owwf2gAXfO8v8WZbJPXBlvRgtZt/GQx9dxWCpP/NryxLpeSWUdsRM8kxbsZTtVl\r
+ kzn/SeBH1yXa/FnPC/HyeTZ+jlrtSGXFbF/UjdOIXt9BP92rTahiIAzhBOypbxNcjSpL\r
+ VPlOsA36ayWJq2UrHkqxShnMSgPk1GDyxyZlEp+dCVELqf0ZfX6Vbxo7rbf+f3ozu0oC\r
+ hAwd5BDeGgitMxFkw51tbkTJdCvPaDwI9Oy8uxyPuvz4fg8dOwsSLxANktKqkDcMA71Y\r
+ 4VMw==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:to:subject:in-reply-to:references:from:date\r
+ :message-id:mime-version;\r
+ bh=OBBsQTs5Gd5Z/5UbLlhX8sWSiDWjUhdTG+wCDm9JH8g=;\r
+ b=dlgNSHgwx4R5WOVFJRhHsVvvI8F/XJEWWCdHm96VIm3XhdxsnrDVxIh6mUSGD0wj5c\r
+ Zo68dcXGW3JyJ33yNW9U7/fORUbeQtOFLa4TYKJcOtfij9O/zG08zvG9n2trnvOdRwKD\r
+ 3dHFAXc8tc6kE9VpAZDOBsgLZ2jKbSzHclvOsFJK1fuIEC/CgG2Tvtczeg7JH2Vv0EYk\r
+ OF2Dfcigfh3t+M75gnnVutmVhjnxjGt/vrH/qIBNkr7SJ8wu01TtSYF8zp/FjJ1kxQo5\r
+ /JzzmVRhwJnfFuS4zevvpLLjL6yB4JUQa/qGuH0hpydon/bnTzR8FIkkapObdKx4J6PA\r
+ vNVQ==\r
+X-Gm-Message-State:\r
+ AEkoouu8DhVHhdRyGp1l1ONOEDPn8GnDKT5ShdU4IraUciTGSPM1CabM0Qdo15s3+HdXxA==\r
+X-Received: by 10.28.50.3 with SMTP id y3mr42351656wmy.23.1469887932116;\r
+ Sat, 30 Jul 2016 07:12:12 -0700 (PDT)\r
+Received: from disaster-area.hh.sledj.net\r
+ ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+ by smtp.gmail.com with ESMTPSA id n7sm21470579wjf.11.2016.07.30.07.12.10\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 30 Jul 2016 07:12:10 -0700 (PDT)\r
+Received: from localhost (disaster-area.hh.sledj.net [local])\r
+ by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 69c63fc6;\r
+ Sat, 30 Jul 2016 14:12:09 +0000 (UTC)\r
+To: Charlie Allom <charlie@yelp.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3] Allow content preference based on message content.\r
+In-Reply-To:\r
+ <m1oa5fuv9v.fsf@YELP-CHARLIE.i-did-not-set--mail-host-address--so-tickle-me>\r
+References: <1459699478-21167-1-git-send-email-dme@dme.org>\r
+ <m1oa5fuv9v.fsf@YELP-CHARLIE.i-did-not-set--mail-host-address--so-tickle-me>\r
+From: David Edmondson <dme@dme.org>\r
+Date: Sat, 30 Jul 2016 15:12:09 +0100\r
+Message-ID: <m21t2bb4g6.fsf@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 30 Jul 2016 14:12:22 -0000\r
+\r
+On Sat, Jul 30 2016, Charlie Allom wrote:\r
+\r
+> Do you have an example for the elisp-challenged, on how to match more\r
+> than one email address? I'm just starting out with emacs but this patch\r
+> is just what I need :)\r
+\r
+There are many ways. This is what I am using:\r
+\r
+  (defun dme:determine-discouraged (msg)\r
+    (let* ((headers (plist-get msg :headers))\r
+          (from (or (plist-get headers :From) "")))\r
+      (cond\r
+       ((string-match (regexp-opt\r
+                      '(\r
+                        ;; Parmiter's parent mail: text/plain with HTML content.\r
+                        "9195404@capita-intouch.co.uk"\r
+                        ;; Oracle mobile reports: text/plain with useless content.\r
+                        "TEMA Alerts"\r
+                        ;; Charles Stanley: HTML only emails.\r
+                        "info@charles-stanley-direct.co.uk"\r
+                        ;; HackerNews: nicer in HTML.\r
+                        "kale@hackernewsletter.com"\r
+                        ;; MasterCard: no content in the text.\r
+                        "CustomerService@information.mbna.co.uk"\r
+                        ))\r
+                     from)\r
+       '("text/plain"))\r
+       (t\r
+       '("text/html" "multipart/related" "text/x-beehive-notification")))))\r
+\r
+\r
+> Regards,\r
+>   Charlie.\r
+>   \r
+> On Sun, Apr 03 2016 at 05:04:37 pm, David Edmondson <dme@dme.org> wrote:\r
+>\r
+>> Allow content preference based on message content.\r
+>>\r
+>> An example configuration might be:\r
+>>\r
+>>   (defun dme:determine-discouraged (msg)\r
+>>     (let* ((headers (plist-get msg :headers))\r
+>>        (from (or (plist-get headers :From) "")))\r
+>>       (cond\r
+>>        ((string-match "9195404@capita-intouch.co.uk" from)\r
+>>     '("text/plain"))\r
+>>        (t\r
+>>     '("text/html" "multipart/related")))))\r
+>>\r
+>>   (setq notmuch-multipart/alternative-discouraged\r
+>>     'dme:determine-discouraged)\r
+>>\r
+>> This would discourage text/html and multipart/related generally, but\r
+>> discourage text/plain should the message be sent from\r
+>> 9195404@capita-intouch.co.uk.\r
+>>\r
+>> v2:\r
+>> - Remove the simple evaluation variant based on feedback.\r
+>>\r
+>> v3:\r
+>> - Merge forward.\r
+>> - Update the example to allow for a nil msg (which should no longer\r
+>>   happen, but it's good to be safe).\r
+>>\r
+>>\r
+>> David Edmondson (1):\r
+>>   emacs: Allow part preferences to depend on message content.\r
+>>\r
+>>  emacs/notmuch-lib.el  | 20 ++++++++++++++++----\r
+>>  emacs/notmuch-show.el |  2 +-\r
+>>  2 files changed, 17 insertions(+), 5 deletions(-)\r
+>\r
+> -- \r