1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 6C13C6DE0314
\r
6 for <notmuch@notmuchmail.org>; Sun, 3 Apr 2016 09:04:53 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.166 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.099, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
\r
13 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,
\r
14 RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001]
\r
16 Received: from arlo.cworth.org ([127.0.0.1])
\r
17 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
18 with ESMTP id tItUJHHdabPg for <notmuch@notmuchmail.org>;
\r
19 Sun, 3 Apr 2016 09:04:45 -0700 (PDT)
\r
20 Received: from mail-lb0-f195.google.com (mail-lb0-f195.google.com
\r
22 by arlo.cworth.org (Postfix) with ESMTPS id 35A576DE01C2
\r
23 for <notmuch@notmuchmail.org>; Sun, 3 Apr 2016 09:04:45 -0700 (PDT)
\r
24 Received: by mail-lb0-f195.google.com with SMTP id bc4so17481049lbc.0
\r
25 for <notmuch@notmuchmail.org>; Sun, 03 Apr 2016 09:04:45 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
27 d=dme-org.20150623.gappssmtp.com; s=20150623;
\r
28 h=from:to:subject:date:message-id:in-reply-to:references;
\r
29 bh=efVU9wQRFFod+ey1vTMyZ9KpeBOt+bqbxJAV+a9l+dk=;
\r
30 b=eFQRy4Ryyb+Kaf15mSIWajUzA92rmuXqXQSIa5AgdZxGuwIutn+rFo6ofVVxt9YmzO
\r
31 C/l9444ab4PhUgoodnhZZ0zJSbjdGXdeWDW0YmJ6php1YqEbLB7KhQ2Zm47KfRpm4F8o
\r
32 1Dg8vdU5Qa+3II48yH/BUvM7fiqPwhuYgGs5cFXucuXRLLYFJ4XurS5AqpmDGfdL32x4
\r
33 LVsG1U0QKI92JZsryBh7EbM5zxx8DzEHgwsAl8SMXVvldChQK5hzHaNugL6iDgdj5gxt
\r
34 ZB+S9pl6XtVMqfedqEUS7ai7PS9ExM0BdSljz852rc319cltHdw9DcGZA0ks3hbZGa0h
\r
36 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
37 d=1e100.net; s=20130820;
\r
38 h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
\r
40 bh=efVU9wQRFFod+ey1vTMyZ9KpeBOt+bqbxJAV+a9l+dk=;
\r
41 b=lUQNV624W6ERZEWNahOJ5k1Nv+BFJDpgWvm1W4KPXx4hOcXp97mA7iPKDx+gow1bnm
\r
42 EBZOl15tHEZ1ZyQ9PUmZpBwWTEjLA+41cQxPBEfhJIn5+52Y9b2K1aPm40QunrTGlVg0
\r
43 Kykockbx5n6oXAToC/M6it+LBC6h39oPSWki4fk2pn9hTR60QbY7OwrbCpzBpgJRAlHg
\r
44 CKgDMKqcDNGRE3ggmGjhKVPAkMV9gX5wT6nyzAsmt/30OeTEWDY/OISNeq7teIsUE/Xm
\r
45 hTTZ9/qKtRUOXQN+1G3kyMDMzm8QPFyrULDYZYzbYGHLiBV/k2wfWxCmG5LCj3OlmOR0
\r
48 AD7BkJI0g2FHLqwMnz9fYlClCXqtXEMFWyRk19YdWopPG183YVyPrQrlAJy72RgOrLEHJg==
\r
49 X-Received: by 10.28.126.65 with SMTP id z62mr7945087wmc.42.1459699483568;
\r
50 Sun, 03 Apr 2016 09:04:43 -0700 (PDT)
\r
51 Received: from disaster-area.hh.sledj.net
\r
52 ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])
\r
53 by smtp.gmail.com with ESMTPSA id gk4sm24351438wjd.7.2016.04.03.09.04.42
\r
54 for <notmuch@notmuchmail.org>
\r
55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
56 Sun, 03 Apr 2016 09:04:42 -0700 (PDT)
\r
57 Received: from localhost (disaster-area.hh.sledj.net [local])
\r
58 by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id d5c60808
\r
59 for <notmuch@notmuchmail.org>; Sun, 3 Apr 2016 16:04:38 +0000 (UTC)
\r
60 From: David Edmondson <dme@dme.org>
\r
61 To: notmuch@notmuchmail.org
\r
62 Subject: [PATCH v3] emacs: Allow part preferences to depend on message
\r
64 Date: Sun, 3 Apr 2016 17:04:38 +0100
\r
65 Message-Id: <1459699478-21167-2-git-send-email-dme@dme.org>
\r
66 X-Mailer: git-send-email 2.1.4
\r
67 In-Reply-To: <1459699478-21167-1-git-send-email-dme@dme.org>
\r
68 References: <1459699478-21167-1-git-send-email-dme@dme.org>
\r
69 X-BeenThere: notmuch@notmuchmail.org
\r
70 X-Mailman-Version: 2.1.20
\r
72 List-Id: "Use and development of the notmuch mail system."
\r
73 <notmuch.notmuchmail.org>
\r
74 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
76 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
77 List-Post: <mailto:notmuch@notmuchmail.org>
\r
78 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
79 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
80 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
81 X-List-Received-Date: Sun, 03 Apr 2016 16:04:53 -0000
\r
83 Currently the preference for which sub-part of a multipart/alternative
\r
84 part is shown is global. Allow to the user to override the settings on a
\r
85 per-message basis by providing the ability to call a function that has
\r
86 access to the message to return the discouraged type list.
\r
88 The original approach is retained as the default.
\r
90 emacs/notmuch-lib.el | 20 ++++++++++++++++----
\r
91 emacs/notmuch-show.el | 2 +-
\r
92 2 files changed, 17 insertions(+), 5 deletions(-)
\r
94 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
95 index 75a3706..eca837d 100644
\r
96 --- a/emacs/notmuch-lib.el
\r
97 +++ b/emacs/notmuch-lib.el
\r
98 @@ -520,11 +520,23 @@ This replaces spaces, percents, and double quotes in STR with
\r
102 -(defun notmuch-multipart/alternative-choose (types)
\r
103 - "Return a list of preferred types from the given list of types"
\r
104 +(defun notmuch-multipart/alternative-determine-discouraged (msg)
\r
105 + "Return the discouraged alternatives for the specified message."
\r
106 + ;; If a function, return the result of calling it.
\r
107 + (if (functionp notmuch-multipart/alternative-discouraged)
\r
108 + (funcall notmuch-multipart/alternative-discouraged msg)
\r
109 + ;; Otherwise simply return the value of the variable, which is
\r
110 + ;; assumed to be a list of discouraged alternatives. This is the
\r
111 + ;; default behaviour.
\r
112 + notmuch-multipart/alternative-discouraged))
\r
114 +(defun notmuch-multipart/alternative-choose (msg types)
\r
115 + "Return a list of preferred types from the given list of types
\r
116 +for this message, if present."
\r
117 ;; Based on `mm-preferred-alternative-precedence'.
\r
118 - (let ((seq types))
\r
119 - (dolist (pref (reverse notmuch-multipart/alternative-discouraged))
\r
120 + (let ((discouraged (notmuch-multipart/alternative-determine-discouraged msg))
\r
122 + (dolist (pref (reverse discouraged))
\r
123 (dolist (elem (copy-sequence seq))
\r
124 (when (string-match pref elem)
\r
125 (setq seq (nconc (delete elem seq) (list elem))))))
\r
126 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
127 index 7c34449..f6a21e4 100644
\r
128 --- a/emacs/notmuch-show.el
\r
129 +++ b/emacs/notmuch-show.el
\r
130 @@ -607,7 +607,7 @@ will return nil if the CID is unknown or cannot be retrieved."
\r
131 (plist-get part :content)))
\r
133 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth button)
\r
134 - (let ((chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
135 + (let ((chosen-type (car (notmuch-multipart/alternative-choose msg (notmuch-show-multipart/*-to-list part))))
\r
136 (inner-parts (plist-get part :content))
\r
138 ;; This inserts all parts of the chosen type rather than just one,
\r