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 2D724431FDF for ; Mon, 12 May 2014 05:29:38 -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 eT9If0j9fzpa for ; Mon, 12 May 2014 05:29:33 -0700 (PDT) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 407A4431FC7 for ; Mon, 12 May 2014 05:29:33 -0700 (PDT) Received: by mail-we0-f177.google.com with SMTP id x48so6656003wes.22 for ; Mon, 12 May 2014 05:29:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fQ6nCL7txEWTecPqU4ztiDfdNjKVzxU2hdZiGm++bhk=; b=ACsfd8P31jenGKdJe/IGdvWwFs6ygp6wuy6dzCG6TinRTGMDTzTegBUVKKX5IdVhsq 4GawgUtdU+XIIXKj0r6fAUvrff7+xsIjpPbnBoemVSATCqcMDYZ48zEmVnN/HsA788T+ TNSPP5F4meGR8ngt57iyjHIVIcii5vCKLZFmi+1hxuvHap7v9VjgY5P8YHEN4XGgRknZ wFNt84vW5twhFW5lSyazHfhV0HDxnAJ6nltI9b3oRsm6HQNPGXDZPzXiD6ks8SjGcsM9 /lRnd1mUmBbhz35yIMD7Ke/X5g+MmD+4KVpiAd7miGoFGgp8VMI4xEiFSBBNnFboVPZC wZGw== X-Gm-Message-State: ALoCoQnOAJNcXF6xzo1X1z1Kxbcmy7mgOhYQgedp4XMwVys7Bs5Ac29qxAMnNjiBBhBcxQboTisL X-Received: by 10.180.78.5 with SMTP id x5mr15515388wiw.12.1399897771989; Mon, 12 May 2014 05:29:31 -0700 (PDT) Received: from hotblack-desiato.hh.sledj.net ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8]) by mx.google.com with ESMTPSA id fu10sm15873680wib.11.2014.05.12.05.29.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 May 2014 05:29:30 -0700 (PDT) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 395A710B324; Mon, 12 May 2014 13:29:29 +0100 (BST) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v3 2/9] emacs/show: Allow the user to decide when part headers should be inserted Date: Mon, 12 May 2014 13:29:22 +0100 Message-Id: <1399897769-26809-3-git-send-email-dme@dme.org> X-Mailer: git-send-email 2.0.0.rc0 In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org> References: <87sixdujkv.fsf@qmul.ac.uk> <1399897769-26809-1-git-send-email-dme@dme.org> 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 12:29:38 -0000 Make the function that determines whether a part header should be inserted a user controlled, with some example functions. --- emacs/notmuch-show.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index ec99141..f78a0ab 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -135,6 +135,17 @@ indentation." :type 'boolean :group 'notmuch-show) +(defcustom notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p-smart + "A function to call to determine whether a MIME part should have a header button. + +The function is passed one argument, PART - the MIME part in +question." + :type 'function + :group 'notmuch-show + :options '(notmuch-show-insert-header-p-smart + notmuch-show-insert-header-p-always + notmuch-show-insert-header-p-never)) + (defvar notmuch-show-thread-id nil) (make-variable-buffer-local 'notmuch-show-thread-id) (put 'notmuch-show-thread-id 'permanent-local t) @@ -880,12 +891,18 @@ message at DEPTH in the current thread." "text/x-diff") content-type))) -(defun notmuch-show-insert-header-p (part) +(defun notmuch-show-insert-header-p-smart (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))))) +(defun notmuch-show-insert-header-p-always (part) + t) + +(defun notmuch-show-insert-header-p-never (part) + nil) + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) "Insert the body part PART at depth DEPTH in the current thread. @@ -904,7 +921,7 @@ useful for quoting in replies)." ;; We omit the part button for the first (or only) part if ;; this is text/plain, or HIDE is 'no-buttons. (button (when (and (not (equal hide 'no-buttons)) - (notmuch-show-insert-header-p part)) + (funcall notmuch-show-insert-header-p-function part)) (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) (content-beg (point))) -- 2.0.0.rc0