[PATCH v3 3/3] emacs: do not call notmuch show for non-inlinable parts
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Mon, 28 Nov 2011 21:13:59 +0000 (01:13 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:28 +0000 (09:40 -0800)
ab/53a05ae2c56bb1f9e0ca7b771f4d413b4e1081 [new file with mode: 0644]

diff --git a/ab/53a05ae2c56bb1f9e0ca7b771f4d413b4e1081 b/ab/53a05ae2c56bb1f9e0ca7b771f4d413b4e1081
new file mode 100644 (file)
index 0000000..72c252e
--- /dev/null
@@ -0,0 +1,136 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5222A429E21\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:14:33 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id DnLnRjMmtbUm for <notmuch@notmuchmail.org>;\r
+       Mon, 28 Nov 2011 13:14:32 -0800 (PST)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 9CC7C431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:14:32 -0800 (PST)\r
+Received: by mail-bw0-f53.google.com with SMTP id q10so9880129bka.26\r
+       for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:14:32 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=H5UBhAF5rC3kz8K6UZpH2YfL+6DFz1hp6r4ooI/I/Sk=;\r
+       b=V9YMfjh4Z3ppJRbv9ikE+lxDufQ1MS82jxVEN9QCIvo0u3eiRH9s8I82meiJUAwh7o\r
+       xot9PcqnnrqMJOPMzeLoP9dEI8ic+CGU/8GHG+js/PEgd7b15fqyc/YctHS68TUF3gSU\r
+       nfCFu8zWNqDjL0NN1mUXe/0LwQuLUXRi4SgWE=\r
+Received: by 10.204.149.215 with SMTP id u23mr48237752bkv.105.1322514872214;\r
+       Mon, 28 Nov 2011 13:14:32 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id cc2sm32323915bkb.8.2011.11.28.13.14.31\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 28 Nov 2011 13:14:31 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 3/3] emacs: do not call notmuch show for non-inlinable\r
+ parts\r
+Date: Tue, 29 Nov 2011 01:13:59 +0400\r
+Message-Id: <1322514839-28441-4-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1322514839-28441-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+       <1322514839-28441-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 28 Nov 2011 21:14:33 -0000\r
+\r
+Before the change, there was a workaround to avoid notmuch show calls\r
+for parts with application/* Content-Type.  But non-inlinable parts\r
+are not limited to this Content-Type (e.g. mp3 files have audio/mpeg\r
+Content-Type and are not inlinable).  For such parts\r
+`notmuch-show-insert-part-*/*' handler is called which unconditionally\r
+fetches contents for all parts.\r
+\r
+The patch moves content fetching from `notmuch-show-insert-part-*/*'\r
+to `notmuch-show-mm-display-part-inline' function after MIME inlinable\r
+checks are done to avoid useless notmuch show calls.  The\r
+application/* hack is no longer needed and removed.\r
+---\r
+ emacs/notmuch-show.el |   17 +++++------------\r
+ test/emacs            |    1 -\r
+ 2 files changed, 5 insertions(+), 13 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index d7fbbca..d2d4968 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -320,17 +320,17 @@ message at DEPTH in the current thread."\r
+       ;; ange-ftp, which is reasonable to use here.\r
+       (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t)))))\r
\r
+-(defun notmuch-show-mm-display-part-inline (msg part content-type content)\r
++(defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
+   "Use the mm-decode/mm-view functions to display a part in the\r
+ current buffer, if possible."\r
+   (let ((display-buffer (current-buffer)))\r
+     (with-temp-buffer\r
+-      (insert content)\r
+       (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
+-      (set-buffer display-buffer)\r
+       (if (and (mm-inlinable-p handle)\r
+                (mm-inlined-p handle))\r
+-          (progn\r
++          (let ((content (notmuch-show-get-bodypart-content msg part nth)))\r
++            (insert content)\r
++            (set-buffer display-buffer)\r
+             (mm-display-part handle)\r
+             t)\r
+         nil)))))\r
+@@ -588,17 +588,10 @@ current buffer, if possible."\r
+               nil))\r
+         nil))))\r
\r
+-(defun notmuch-show-insert-part-application/* (msg part content-type nth depth declared-type\r
+-)\r
+-  ;; do not render random "application" parts\r
+-  (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename)))\r
+-\r
+ (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
+   ;; This handler _must_ succeed - it is the handler of last resort.\r
+   (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
+-  (let ((content (notmuch-show-get-bodypart-content msg part nth)))\r
+-    (if content\r
+-      (notmuch-show-mm-display-part-inline msg part content-type content)))\r
++  (notmuch-show-mm-display-part-inline msg part nth content-type)\r
+   t)\r
\r
+ ;; Functions for determining how to handle MIME parts.\r
+diff --git a/test/emacs b/test/emacs\r
+index bdac84f..42e5d61 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -488,7 +488,6 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))\r
+ test_expect_equal $(notmuch_counter_value) 1\r
\r
+ test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"\r
+-test_subtest_known_broken\r
+ id='message-with-audio/mpeg-attachment@notmuchmail.org'\r
+ emacs_deliver_message \\r
+     'Message with audio/mpeg attachment' \\r
+-- \r
+1.7.7.3\r
+\r