From: David Edmondson Date: Tue, 13 May 2014 09:47:22 +0000 (+0100) Subject: Re: [PATCH v3 1/9] emacs/show: Re-arrange determination if a part header is necessary X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=af86b103ef81b4e46e49e10b72df32b7f946fb36;p=notmuch-archives.git Re: [PATCH v3 1/9] emacs/show: Re-arrange determination if a part header is necessary --- diff --git a/ed/a33a4d64e47d00fcabba0abc9848979d2d9c82 b/ed/a33a4d64e47d00fcabba0abc9848979d2d9c82 new file mode 100644 index 000000000..2db64ea37 --- /dev/null +++ b/ed/a33a4d64e47d00fcabba0abc9848979d2d9c82 @@ -0,0 +1,167 @@ +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 148C6431FC2 + for ; Tue, 13 May 2014 02:47:39 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 6XUKKKV6R7SJ for ; + Tue, 13 May 2014 02:47:31 -0700 (PDT) +Received: from mail-we0-f182.google.com (mail-we0-f182.google.com + [74.125.82.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 04DE0431FAF + for ; Tue, 13 May 2014 02:47:30 -0700 (PDT) +Received: by mail-we0-f182.google.com with SMTP id t60so101544wes.13 + for ; Tue, 13 May 2014 02:47:29 -0700 (PDT) +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:user-agent + :from:date:message-id:mime-version:content-type; + bh=jyF/oyfkO3Mt9YqRzy/YRokhBC640rN/sFam1lOU0Lk=; + b=EOvlTNb3rAyHE3oJTPh499njLAxRIfIkQEPKIIly5dT+j1fVLt3hiaj9oKTBlXFosS + tapmJENGrU4tmO5HfU/rOljl6V952rHINNVjoROFNDXkOTP4Hs1Jnn+HuyZB48Gr1qmU + bzAmOslQCueW4KjlZzwkacXnCNlpwdPC5j1Fs0qhws3hW9ETMy9q28iSM5kYzbjiHbRF + vlsOhb7QwxDmG3WkgEl5BOpf41mbpH2Lcx19yFslmD85CfamZ65drSB8/m6d9Byg+bWO + 8vkGK/poQ2By9YYa1fM3u1NeyCIuSOATDvprdCEXDtPlSp8lb6bxCx3DKGKzTe0Ga6B3 + Shkw== +X-Gm-Message-State: + ALoCoQmZRNXPlNq/Jua4Cd3MCtrVVbqU0058oVRruW14T6MWvoN4UWFP3ZdpO+jRwImmS7I9gYAz +X-Received: by 10.195.13.76 with SMTP id ew12mr702135wjd.80.1399974449609; + Tue, 13 May 2014 02:47:29 -0700 (PDT) +Received: from localhost ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8]) + by mx.google.com with ESMTPSA id 12sm21512017wju.48.2014.05.13.02.47.27 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 13 May 2014 02:47:28 -0700 (PDT) +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 1/9] emacs/show: Re-arrange determination if a part + header is necessary +In-Reply-To: <87sioek5sz.fsf@qmul.ac.uk> +References: <87sixdujkv.fsf@qmul.ac.uk> + <1399897769-26809-1-git-send-email-dme@dme.org> + <1399897769-26809-2-git-send-email-dme@dme.org> + <87sioek5sz.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +From: David Edmondson +Date: Tue, 13 May 2014 10:47:22 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha1; protocol="application/pgp-signature" +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, 13 May 2014 09:47:39 -0000 + +--=-=-= +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, May 12 2014, Mark Walters wrote: +> On Mon, 12 May 2014, David Edmondson wrote: +>> 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 10fc872..ec99141 100644 +>> --- a/emacs/notmuch-show.el +>> +++ b/emacs/notmuch-show.el +>> @@ -871,6 +871,21 @@ message at DEPTH in the current thread." +>> ;; showable this returns nil. +>> (notmuch-show-create-part-overlays button part-beg part-end)))) +>>=20=20 +>> +(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=3D content-type "application/octet-stream") +>> + (notmuch-show-get-mime-type-of-application/octet-stream part)) +>> + (and (string=3D content-type "inline patch") +>> + "text/x-diff") +>> + content-type))) +>> + +>> +(defun notmuch-show-insert-header-p (part) +>> + "Return non-NIL if a header button should be inserted for this part." +>> + (let ((mime-type (notmuch-show-mime-type part))) +>> + (not (and (string=3D mime-type "text/plain") +>> + (<=3D (plist-get part :id) 1))))) +> +> My only query here is whether a notmuch-show-hide-header-p (part) might +> make some of the logic clearer? + +You're suggesting to simply invert the sense of the function? +> +> MW +> +> +>> + +>> (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +>> "Insert the body part PART at depth DEPTH in the current thread. +>>=20=20 +>> @@ -881,19 +896,15 @@ is t, hide the part initially and show the button.= + If HIDE is +>> useful for quoting in replies)." +>>=20=20 +>> (let* ((content-type (downcase (plist-get part :content-type))) +>> - (mime-type (or (and (string=3D content-type "application/octet-stream= +") +>> - (notmuch-show-get-mime-type-of-application/octet-stream part)) +>> - (and (string=3D content-type "inline patch") +>> - "text/x-diff") +>> - content-type)) +>> + (mime-type (notmuch-show-mime-type part)) +>> (nth (plist-get part :id)) +>> (beg (point)) +>> ;; Hide the part initially if HIDE is t. +>> (show-part (not (equal hide t))) +>> ;; We omit the part button for the first (or only) part if +>> ;; this is text/plain, or HIDE is 'no-buttons. +>> - (button (unless (or (equal hide 'no-buttons) +>> - (and (string=3D mime-type "text/plain") (<=3D nth 1))) +>> + (button (when (and (not (equal hide 'no-buttons)) +>> + (notmuch-show-insert-header-p part)) +>> (notmuch-show-insert-part-header nth mime-type content-type (plist= +-get part :filename)))) +>> (content-beg (point))) +>>=20=20 +>> --=20 +>> 2.0.0.rc0 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch + +--=-=-= +Content-Type: application/pgp-signature; name="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iKYEARECAGYFAlNx6ipfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl +bnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1M0Y5NDJDMEExNjc3MDE4OURGMUYyMDY5 +RUNEMEFCRjA0OTY1MTYACgkQaezQq/BJZRbHVQCffqqBuh+DKGalBH+hmacDsjjj +UGYAoIwEjXh00e/UYzPKaasGd8A+NDWg +=rrCA +-----END PGP SIGNATURE----- +--=-=-=--