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 7759C431FC0 for ; Tue, 30 Jul 2013 09:15:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=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 U8p2OVj7dLnx for ; Tue, 30 Jul 2013 09:15:07 -0700 (PDT) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C0EC5431FBF for ; Tue, 30 Jul 2013 09:15:06 -0700 (PDT) Received: by mail-wg0-f48.google.com with SMTP id f12so5579926wgh.15 for ; Tue, 30 Jul 2013 09:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=bcay4ULQWLHUKCBhZdxcsVLmgxszGt+VYI7h+Jg50M0=; b=gEHAAhl7t9blskjE83GDa1uSZVyL6Eu/3nSpWRKtvxZZSjWCGN6xwJY9HVFkgfD8GN NUkLCajt1mGMy7ZyxyuSpjb+VqFNDS/yY0fBQgTyRnbbEVVwm+mTJwCfBi5ltr0RGYX0 nNkGHQgbqUDYEfVVHdKY3NoD9uTnwMGg1Sv5PFyataf0iF/rhXwVQkfuGD9VCCqTKseO PbfYukNsLMsjN549Ja9sV0nu+zJOJyg3EK+c4359gVnBd0laH11VLnRzyNGsEXgNSHsO 9dDyije0PgBX+ZGR1959CUbwJuf2CEFspCS4YJ5QsXswC6Jq1prWtFiJv70cpTsg6ecf V3wg== X-Received: by 10.194.219.198 with SMTP id pq6mr47256898wjc.58.1375200905629; Tue, 30 Jul 2013 09:15:05 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id i1sm29550731wiz.6.2013.07.30.09.15.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 30 Jul 2013 09:15:04 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] emacs: bugfix attachment content-type as mime-type handling Date: Tue, 30 Jul 2013 17:15:00 +0100 Message-Id: <1375200900-5650-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <87li4om623.fsf@qmul.ac.uk> References: <87li4om623.fsf@qmul.ac.uk> 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, 30 Jul 2013 16:15:14 -0000 Notmuch puts attachments in as declared content-type except when the content-type is application/octet-stream it tries to guess the type from the filename/extension. This means that viewing a pdf (for example) which is sent as application/octet-strem invokes the pdf viewer rather than just offering to save the part. Recent changes to the attachment handling (commit 1546387d) changed (broke) this. This patch stores the calculated mime-type with the part and changes the attachment part handlers can use it instead. --- This seems to fix the bug for me. I am not sure I like the naming (mime-type/content-type). Maybe it would be better to be explicit with something like calculated-content-type but probably that should be a more wholesale renaming. Best wishes Mark emacs/notmuch-show.el | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index c4e0a99..9f47f5e 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -892,6 +892,9 @@ If HIDE is non-nil then initially hide this part." (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) (content-beg (point))) + ;; Store the calculated mime-type for later use (e.g. by attachment handlers). + (plist-put part :mime-type mime-type) + (if (not hide) (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) (button-put button :notmuch-lazy-part @@ -2055,10 +2058,10 @@ caller is responsible for killing this buffer as appropriate." (message-id (notmuch-show-get-message-id)) (nth (plist-get part :id)) (buf (notmuch-show-generate-part-buffer message-id nth)) - (content-type (plist-get part :content-type)) + (mime-type (plist-get part :mime-type)) (filename (plist-get part :filename)) (disposition (if filename `(attachment (filename . ,filename))))) - (mm-make-handle buf (list content-type) nil nil disposition))) + (mm-make-handle buf (list mime-type) nil nil disposition))) (defun notmuch-show-apply-to-current-part-handle (fn) "Apply FN to an mm-handle for the part containing point. -- 1.7.9.1