From ed1f63c4741095c63f71055f9853406929a756e6 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Tue, 9 Feb 2016 20:28:38 +0000 Subject: [PATCH] Re: [PATCH v4 1/7] emacs/show: Re-arrange determination if a part header is necessary --- 01/cdec53eaaf507fb77a1e83ac3d0645a4aad4b7 | 152 ++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 01/cdec53eaaf507fb77a1e83ac3d0645a4aad4b7 diff --git a/01/cdec53eaaf507fb77a1e83ac3d0645a4aad4b7 b/01/cdec53eaaf507fb77a1e83ac3d0645a4aad4b7 new file mode 100644 index 000000000..373da201a --- /dev/null +++ b/01/cdec53eaaf507fb77a1e83ac3d0645a4aad4b7 @@ -0,0 +1,152 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 632466DE13A6 + for ; Tue, 9 Feb 2016 12:28:44 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.069 +X-Spam-Level: +X-Spam-Status: No, score=-0.069 tagged_above=-999 required=5 + tests=[AWL=-0.002, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id TbQVHJ5cBmqP for ; + Tue, 9 Feb 2016 12:28:42 -0800 (PST) +Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com + [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 2CA886DE01D3 for + ; Tue, 9 Feb 2016 12:28:42 -0800 (PST) +Received: by mail-wm0-f65.google.com with SMTP id 128so30413wmz.3 + for ; Tue, 09 Feb 2016 12:28:42 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=dme-org.20150623.gappssmtp.com; s=20150623; + h=to:subject:in-reply-to:references:from:date:message-id:mime-version + :content-type; bh=a5qY8PX+8mdfx948wkY3RPM7iQ1WDROD/w5EDqcDsJo=; + b=Bp0lK6yNYC3Gb3LOLhJTyBqHmL9eIDCdYyPgo0dJnL/qRljQaDLYS0jeHOrlMOl+Zx + MsQrT68y1lZSuh4klCUa93UGuNyqSMX2guZ3lBRv1EpJNSlFynHonEAH8jSBy4J5ZiVK + gRDjXDxxhnaeBZIDvWC1cmb20GMyFJAc7w8shsMkzBnFtrqAAVecxsRq/t4wPG6KAVDZ + nv64k/CNYOudQswtmn6J9/vOBqYhanBNyXgf1ZoAcZWasarNv/lTh/8nO62l9dxafWa5 + Xt5qHFbDQgqFM/DlnlUYuHdiuB0tpoG1TLAVgTuNRRrR34Dxva9Nhwxroxiyibijcf1m + 2L0A== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:to:subject:in-reply-to:references:from:date + :message-id:mime-version:content-type; + bh=a5qY8PX+8mdfx948wkY3RPM7iQ1WDROD/w5EDqcDsJo=; + b=KWtr1IuPXTIPGbIR8Wpuzqkswx8ZaXW9YJNIC3+qYkdmzHVcafa7BtyFNev8zQd22p + I1YInVnLa8E7N7+z8hLDp8VDbiR2ZHjkIoT88ldRl9qzLjey3aTdao4Kb9tYVAXZ76uT + OpsNT6+8sP0f5N0fld6NW6Uhufjyc20gEqTWcP4BE6gzXOtMhBUZsBvM9lFsF4V2w9Sp + rHuxuTPTk70JzrVKNowXUr6hPPhtUkVwsCu5Dj7LK6QJd0VXitSVyP4YM90dB/qL4gW1 + BerNWacrEEBCyllkj04l9plfUJcaYlyIYtAjy//A6P1Vr9r4tTQowOtTsCwsXnctyV67 + UYwg== +X-Gm-Message-State: + AG10YORc24I6AZCkjzevYxXVEwTFBNWhelT/zhtp1cwZ+AWHDjdsAFzbmG1XnNqWtgfU7g== +X-Received: by 10.28.131.134 with SMTP id f128mr7160601wmd.41.1455049720860; + Tue, 09 Feb 2016 12:28:40 -0800 (PST) +Received: from disaster-area.hh.sledj.net + ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) + by smtp.gmail.com with ESMTPSA id c136sm19053937wmd.3.2016.02.09.12.28.39 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 09 Feb 2016 12:28:39 -0800 (PST) +Received: from localhost (disaster-area.hh.sledj.net [local]) + by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 6601a644; + Tue, 9 Feb 2016 20:28:38 +0000 (UTC) +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v4 1/7] emacs/show: Re-arrange determination if a part + header is necessary +In-Reply-To: <1446894276-7814-2-git-send-email-markwalters1009@gmail.com> +References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> + <1446894276-7814-2-git-send-email-markwalters1009@gmail.com> +From: David Edmondson +Date: Tue, 09 Feb 2016 20:28:38 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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, 09 Feb 2016 20:28:44 -0000 + +On Sat, Nov 07 2015, Mark Walters wrote: +> From: David Edmondson +> +> Move the determination of whether a part header is required to a +> distinct function. +> --- +> emacs/notmuch-show.el | 25 ++++++++++++++++++------- +> 1 file changed, 18 insertions(+), 7 deletions(-) +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 49fd198..47a02e5 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -929,6 +929,21 @@ (defun notmuch-show-lazy-part (part-args button) +> ;; showable this returns nil. +> (notmuch-show-create-part-overlays button part-beg part-end)))) +> +> +(defun notmuch-show-mime-type (part) +> + "Return the correct mime-type to use for PART." +> + (let ((content-type (downcase (plist-get part :content-type)))) +> + (or (and (string= content-type "application/octet-stream") +> + (notmuch-show-get-mime-type-of-application/octet-stream part)) +> + (and (string= content-type "inline patch") +> + "text/x-diff") +> + content-type))) +> + +> +(defun notmuch-show-insert-header-p (part hide) +> + "Return non-NIL if a header button should be inserted for this part." +> + (let ((mime-type (notmuch-show-mime-type part))) +> + (not (and (string= mime-type "text/plain") +> + (<= (plist-get part :id) 1))))) + +It would be nice to have a comment here that explained the logic being +applied (i.e. parts get a header unless they are text/plain and the +first part). (It actually took me a minute to figure out what the logic +was...) + +> + +> (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +> "Insert the body part PART at depth DEPTH in the current thread. +> +> @@ -939,11 +954,7 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +> useful for quoting in replies)." +> +> (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)) +> - (and (string= content-type "inline patch") +> - "text/x-diff") +> - content-type)) +> + (mime-type (notmuch-show-mime-type part)) +> (nth (plist-get part :id)) +> (long (and (notmuch-match-content-type mime-type "text/*") +> (> notmuch-show-max-text-part-size 0) +> @@ -951,8 +962,8 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +> (beg (point)) +> ;; We omit the part button for the first (or only) part if +> ;; this is text/plain, or HIDE is 'no-buttons. + +Part of this comment now belongs up above. + +> - (button (unless (or (equal hide 'no-buttons) +> - (and (string= mime-type "text/plain") (<= nth 1))) +> + (button (when (and (not (equal hide 'no-buttons)) +> + (notmuch-show-insert-header-p part hide)) +> (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) +> ;; Hide the part initially if HIDE is t, or if it is too long +> ;; and we have a button to allow toggling (thus reply which +> -- +> 2.1.4 -- 2.26.2