Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 52DBC431FB6 for ; Tue, 29 Nov 2011 13:20:38 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id riZjEajMM-hG for ; Tue, 29 Nov 2011 13:20:37 -0800 (PST) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 29F86429E33 for ; Tue, 29 Nov 2011 13:20:31 -0800 (PST) Received: by mail-bw0-f53.google.com with SMTP id q10so11590721bka.26 for ; Tue, 29 Nov 2011 13:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=H5UBhAF5rC3kz8K6UZpH2YfL+6DFz1hp6r4ooI/I/Sk=; b=NQ380rdTV4yhGkX5mCryYFlcXQcGrAbWHExUQ6cGZnUe1Ja97qFyB8xkhVqBYh8Lvb +lGK1XHexpiOuMJp9n9arBrYEG2Np7lKSZtNhkKrFJWVT3tyoqHGQKNwEkrtMvHymUdo G5+e6ItjHiMxd9PcYcBd2P0eYQWDshjDIJQcQ= Received: by 10.205.139.81 with SMTP id iv17mr25061247bkc.118.1322601630566; Tue, 29 Nov 2011 13:20:30 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id d2sm16293513bky.11.2011.11.29.13.20.29 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Nov 2011 13:20:29 -0800 (PST) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH v4 3/3] emacs: do not call notmuch show for non-inlinable parts Date: Wed, 30 Nov 2011 01:19:54 +0400 Message-Id: <1322601595-20537-4-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1322601595-20537-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com> <1322601595-20537-1-git-send-email-dmitry.kurochkin@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Tue, 29 Nov 2011 21:20:38 -0000 Before the change, there was a workaround to avoid notmuch show calls for parts with application/* Content-Type. But non-inlinable parts are not limited to this Content-Type (e.g. mp3 files have audio/mpeg Content-Type and are not inlinable). For such parts `notmuch-show-insert-part-*/*' handler is called which unconditionally fetches contents for all parts. The patch moves content fetching from `notmuch-show-insert-part-*/*' to `notmuch-show-mm-display-part-inline' function after MIME inlinable checks are done to avoid useless notmuch show calls. The application/* hack is no longer needed and removed. --- emacs/notmuch-show.el | 17 +++++------------ test/emacs | 1 - 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index d7fbbca..d2d4968 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -320,17 +320,17 @@ message at DEPTH in the current thread." ;; ange-ftp, which is reasonable to use here. (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t))))) -(defun notmuch-show-mm-display-part-inline (msg part content-type content) +(defun notmuch-show-mm-display-part-inline (msg part nth content-type) "Use the mm-decode/mm-view functions to display a part in the current buffer, if possible." (let ((display-buffer (current-buffer))) (with-temp-buffer - (insert content) (let ((handle (mm-make-handle (current-buffer) (list content-type)))) - (set-buffer display-buffer) (if (and (mm-inlinable-p handle) (mm-inlined-p handle)) - (progn + (let ((content (notmuch-show-get-bodypart-content msg part nth))) + (insert content) + (set-buffer display-buffer) (mm-display-part handle) t) nil))))) @@ -588,17 +588,10 @@ current buffer, if possible." nil)) nil)))) -(defun notmuch-show-insert-part-application/* (msg part content-type nth depth declared-type -) - ;; do not render random "application" parts - (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))) - (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type) ;; This handler _must_ succeed - it is the handler of last resort. (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename)) - (let ((content (notmuch-show-get-bodypart-content msg part nth))) - (if content - (notmuch-show-mm-display-part-inline msg part content-type content))) + (notmuch-show-mm-display-part-inline msg part nth content-type) t) ;; Functions for determining how to handle MIME parts. diff --git a/test/emacs b/test/emacs index bdac84f..42e5d61 100755 --- a/test/emacs +++ b/test/emacs @@ -488,7 +488,6 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\")) test_expect_equal $(notmuch_counter_value) 1 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts" -test_subtest_known_broken id='message-with-audio/mpeg-attachment@notmuchmail.org' emacs_deliver_message \ 'Message with audio/mpeg attachment' \ -- 1.7.7.3