Re: Flat search and threaded views
[notmuch-archives.git] / 35 / ef81d335bf924e58b7531ffc26b0d5065522f6
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 olra.theworths.org (Postfix) with ESMTP id B6DA4429E25\r
6         for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:28:48 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id PZD+25WvZd6U for <notmuch@notmuchmail.org>;\r
17         Sun, 27 Nov 2011 19:28:46 -0800 (PST)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id E221F429E32\r
22         for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:28:45 -0800 (PST)\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so8621145bka.26\r
24         for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:28:45 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=3poQdV0M28AxQ6Ldz3fRONN+OZ5PIME+7fDBC0jOhbc=;\r
28         b=d95fOVBgqXnqYYVwK2O7RkDWWKl29O2l2Kz9XUO2JSTjnPLdJYN4x/aDKFUMJyjYtZ\r
29         Ksp7E4ZXIV8P0IjD9pV9BKSrWL9mwN3DpN4m8OxpQu8aeh5GlM72mufJwNWRYWS6pDxP\r
30         j31VYUmPzBKRCrgKbGuPzLwT4wCy+9vaJoOKA=\r
31 Received: by 10.204.129.70 with SMTP id n6mr44278447bks.0.1322450925569;\r
32         Sun, 27 Nov 2011 19:28:45 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id c4sm26736150bkk.13.2011.11.27.19.28.44\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Sun, 27 Nov 2011 19:28:45 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 3/3] emacs: do not call notmuch show for non-inlinable parts\r
40 Date: Mon, 28 Nov 2011 07:28:15 +0400\r
41 Message-Id: <1322450895-32523-4-git-send-email-dmitry.kurochkin@gmail.com>\r
42 X-Mailer: git-send-email 1.7.7.3\r
43 In-Reply-To: <1322450895-32523-1-git-send-email-dmitry.kurochkin@gmail.com>\r
44 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45         <1322450895-32523-1-git-send-email-dmitry.kurochkin@gmail.com>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Mon, 28 Nov 2011 03:28:48 -0000\r
59 \r
60 Before the change, there was a workaround to avoid notmuch show calls\r
61 for parts with application/* Content-Type.  But non-inlinable parts\r
62 are not limited to this Content-Type (e.g. mp3 files have audio/mpeg\r
63 Content-Type and are not inlinable).  For such parts\r
64 `notmuch-show-insert-part-*/*' handler is called which unconditionally\r
65 fetches contents for all parts.\r
66 \r
67 The patch moves content fetching from `notmuch-show-insert-part-*/*'\r
68 to `notmuch-show-mm-display-part-inline' function after MIME inlinable\r
69 checks are done to avoid useless notmuch show calls.  The\r
70 application/* hack is no longer needed and removed.\r
71 ---\r
72  emacs/notmuch-show.el |   17 +++++------------\r
73  test/emacs            |    1 -\r
74  2 files changed, 5 insertions(+), 13 deletions(-)\r
75 \r
76 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
77 index d7fbbca..d2d4968 100644\r
78 --- a/emacs/notmuch-show.el\r
79 +++ b/emacs/notmuch-show.el\r
80 @@ -320,17 +320,17 @@ message at DEPTH in the current thread."\r
81         ;; ange-ftp, which is reasonable to use here.\r
82         (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t)))))\r
83  \r
84 -(defun notmuch-show-mm-display-part-inline (msg part content-type content)\r
85 +(defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
86    "Use the mm-decode/mm-view functions to display a part in the\r
87  current buffer, if possible."\r
88    (let ((display-buffer (current-buffer)))\r
89      (with-temp-buffer\r
90 -      (insert content)\r
91        (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
92 -       (set-buffer display-buffer)\r
93         (if (and (mm-inlinable-p handle)\r
94                  (mm-inlined-p handle))\r
95 -           (progn\r
96 +           (let ((content (notmuch-show-get-bodypart-content msg part nth)))\r
97 +             (insert content)\r
98 +             (set-buffer display-buffer)\r
99               (mm-display-part handle)\r
100               t)\r
101           nil)))))\r
102 @@ -588,17 +588,10 @@ current buffer, if possible."\r
103                 nil))\r
104           nil))))\r
105  \r
106 -(defun notmuch-show-insert-part-application/* (msg part content-type nth depth declared-type\r
107 -)\r
108 -  ;; do not render random "application" parts\r
109 -  (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename)))\r
110 -\r
111  (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
112    ;; This handler _must_ succeed - it is the handler of last resort.\r
113    (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
114 -  (let ((content (notmuch-show-get-bodypart-content msg part nth)))\r
115 -    (if content\r
116 -       (notmuch-show-mm-display-part-inline msg part content-type content)))\r
117 +  (notmuch-show-mm-display-part-inline msg part nth content-type)\r
118    t)\r
119  \r
120  ;; Functions for determining how to handle MIME parts.\r
121 diff --git a/test/emacs b/test/emacs\r
122 index 20f8449..56ca87b 100755\r
123 --- a/test/emacs\r
124 +++ b/test/emacs\r
125 @@ -488,7 +488,6 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))\r
126  test_expect_equal $(notmuch_counter_value) 1\r
127  \r
128  test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"\r
129 -test_subtest_known_broken\r
130  id='message-with-audio/mpeg-attachment@notmuchmail.org'\r
131  emacs_deliver_message \\r
132      'Message with audio/mpeg attachment' \\r
133 -- \r
134 1.7.7.3\r
135 \r