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 09A47431FC2 for ; Mon, 12 May 2014 15:09:44 -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 i-4cPO4TtzHM for ; Mon, 12 May 2014 15:09:38 -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 13235431FAF for ; Mon, 12 May 2014 15:09:37 -0700 (PDT) Received: by mail-wi0-f179.google.com with SMTP id bs8so5295556wib.0 for ; Mon, 12 May 2014 15:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=9v5pVKRXzGjfLG7NDUBE5FhJWbb3xKQXVRIAz1xk1iw=; b=uiCzT+f7pnsCKTHrZTf14XtCFCyJbsO+MjnXfsZvSW76rNlbdBFbND047C/bxFBNpk 4AAjpvqbdY5KRPeRbPa3Wq33gl1th2DSJR4jIo07/t5DFMNJp0n/xZZ1QvFEbDFzDayA DKWLEyKicQXY5pJzNr11t/fTv4WkSNeDtaJ7JN50eS/IuqsIP6G9p4aYG85327ALZ8Sm 470MKlO04xuWZx0e5W7Oni2ZmW4AOilE0IbHtRXgcvgLTP10Hlebtjd3shonh9w3VdE/ 5dl99w+SspXLnW2M4tSZ0SbQ6ecriRgA9y9VCKePOum9jkRXS6oYjdnLrbMMy9irQcIr 4aOw== X-Received: by 10.180.106.194 with SMTP id gw2mr17795045wib.47.1399932575656; Mon, 12 May 2014 15:09:35 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by mx.google.com with ESMTPSA id em5sm8590044wic.23.2014.05.12.15.09.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 May 2014 15:09:35 -0700 (PDT) From: Mark Walters To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v3 1/9] emacs/show: Re-arrange determination if a part header is necessary In-Reply-To: <1399897769-26809-2-git-send-email-dme@dme.org> References: <87sixdujkv.fsf@qmul.ac.uk> <1399897769-26809-1-git-send-email-dme@dme.org> <1399897769-26809-2-git-send-email-dme@dme.org> User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Mon, 12 May 2014 23:09:32 +0100 Message-ID: <87sioek5sz.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Mon, 12 May 2014 22:09:44 -0000 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)))) > > +(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) > + "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))))) My only query here is whether a notmuch-show-hide-header-p (part) might make some of the logic clearer? MW > + > (defun notmuch-show-insert-bodypart (msg part depth &optional hide) > "Insert the body part PART at depth DEPTH in the current thread. > > @@ -881,19 +896,15 @@ is t, hide the part initially and show the button. If HIDE is > 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)) > (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= mime-type "text/plain") (<= 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))) > > -- > 2.0.0.rc0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch