From: Mark Walters Date: Sat, 4 May 2013 13:01:14 +0000 (+0100) Subject: [PATCH 1/4] emacs:show: separate out handling of application/octet-stream X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=71dd98d1f6c824ac2d2d5cf476b3586651502eaf;p=notmuch-archives.git [PATCH 1/4] emacs:show: separate out handling of application/octet-stream --- diff --git a/3b/ac6af94f4fa350a3a158b1955f15f6f1801bbd b/3b/ac6af94f4fa350a3a158b1955f15f6f1801bbd new file mode 100644 index 000000000..e4b83e13f --- /dev/null +++ b/3b/ac6af94f4fa350a3a158b1955f15f6f1801bbd @@ -0,0 +1,123 @@ +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 D4CDE431FAF + for ; Sat, 4 May 2013 06:01:33 -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 xtJAYDQnDQJu for ; + Sat, 4 May 2013 06:01:28 -0700 (PDT) +Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com + [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 29B90431FB6 + for ; Sat, 4 May 2013 06:01:28 -0700 (PDT) +Received: by mail-wi0-f179.google.com with SMTP id l13so1365123wie.6 + for ; Sat, 04 May 2013 06:01:27 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to + :references; bh=b2dzy7QmwGFP+t+dbduyCCJCKQvVTX9zeZNIO0wy4GY=; + b=q5PGVB2aSnPkVJVlSWvI9Y7COul9DmT7VSR2tjiu7whViE8V/BnJ6gLn2yPRvP9dKj + +c/+62LTidvumvO7uFNL3vdnfAWP6V17yso6T3NO85dtkhpJJrrGBCvaXTCq4EMTu7pV + 3M9LbC40Pwgke+vjJ8SJI6FLdRXrB2qxcaylY6gifhXWUW+tMukiovHdFgFEq2xfoWnK + Y9fiaLClKNDJDRYhgIEFp12Z1/79XtUBq2ErmPspIkeSH3KmgAtayxcsyVkn0ZtrjjQA + +oFsCT0j+o/jNi46+TnVKdX9fFlTyCiLX+lW8nuBBz6IofOSLGGm+yBjtVwtJBcsMVvk + Aixg== +X-Received: by 10.194.5.196 with SMTP id u4mr18216453wju.54.1367672487061; + Sat, 04 May 2013 06:01:27 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id x13sm3143486wib.3.2013.05.04.06.01.26 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 04 May 2013 06:01:26 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 1/4] emacs:show: separate out handling of + application/octet-stream +Date: Sat, 4 May 2013 14:01:14 +0100 +Message-Id: <1367672478-12247-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1367672478-12247-1-git-send-email-markwalters1009@gmail.com> +References: <1367672478-12247-1-git-send-email-markwalters1009@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: Sat, 04 May 2013 13:01:34 -0000 + +Currently mime parts are basically handled based on their mime-type +with the exception of application/octet-stream parts. Deal with these +parts at the top level (notmuch-show-insert-bodypart). + +This is needed later in the series as we need to put in a part button +for each part (which means knowing its mime type) while deferring the +actual insertion of the part. +--- + emacs/notmuch-show.el | 19 +++++++++++-------- + 1 files changed, 11 insertions(+), 8 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index face2a0..3b9a2ad 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -796,9 +796,9 @@ message at DEPTH in the current thread." + (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type) + (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type)) + +-(defun notmuch-show-insert-part-application/octet-stream (msg part content-type nth depth declared-type) ++(defun notmuch-show-get-mime-type-of-application/octet-stream (part) + ;; If we can deduce a MIME type from the filename of the attachment, +- ;; do so and pass it on to the handler for that type. ++ ;; we return that. + (if (plist-get part :filename) + (let ((extension (file-name-extension (plist-get part :filename))) + mime-type) +@@ -808,7 +808,7 @@ message at DEPTH in the current thread." + (setq mime-type (mailcap-extension-to-mime extension)) + (if (and mime-type + (not (string-equal mime-type "application/octet-stream"))) +- (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type) ++ mime-type + nil)) + nil)))) + +@@ -885,11 +885,14 @@ message at DEPTH in the current thread." + "Insert the body part PART at depth DEPTH in the current thread. + + If HIDE is non-nil then initially hide this part." +- (let ((content-type (downcase (plist-get part :content-type))) +- (nth (plist-get part :id)) +- (beg (point))) +- +- (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type) ++ (let* ((content-type (downcase (plist-get part :content-type))) ++ (mime-type (or (and (string= content-type "application/octet-stream") ++ (notmuch-show-get-mime-type-of-application/octet-stream part)) ++ content-type)) ++ (nth (plist-get part :id)) ++ (beg (point))) ++ ++ (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type) + ;; Some of the body part handlers leave point somewhere up in the + ;; part, so we make sure that we're down at the end. + (goto-char (point-max)) +-- +1.7.9.1 +