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 3B1F66DE1B74 for ; Sat, 7 Nov 2015 03:05:06 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.204 X-Spam-Level: X-Spam-Status: No, score=0.204 tagged_above=-999 required=5 tests=[AWL=0.074, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-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 ePV1OKWBiqmF for ; Sat, 7 Nov 2015 03:05:04 -0800 (PST) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by arlo.cworth.org (Postfix) with ESMTPS id 4AA7C6DE199D for ; Sat, 7 Nov 2015 03:04:53 -0800 (PST) Received: by wmww144 with SMTP id w144so46070212wmw.1 for ; Sat, 07 Nov 2015 03:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nFOhLhaDucbDYlVZAxrmGPvt2GeuuPGKcfY9Fe9+hyk=; b=HNoGQHHN2WzZsL+4jNoUgtJZNi8r5vLLmhHVyXsqhD/5HNPA84e15MO6dTd6tDpq83 q/YbGfaJRgrJHiAR9T/xyWEvBF854Bj190dFvOnF5sqnn0k4UmzrKby3/KG+Vbu8qmOQ nvBdy0/vVYwmap/QDpjduuOs7UzCtSDx2RbHRtJ0a8h9rvEa1YTG+OSCRJ7j+u8EbBuF 40UNzcaj204Rs6U9QS3REQxaESFbWjoKSD+hapyNqMLwXQxuLw8hBCDTx8mdDKqHkyDS b0uH3jHofX5jO3BwuUExbv4/LI/SGxIMVKTGh8s09DjQ+Dsnsu8Ybx757XjZazDZak8J 666g== X-Received: by 10.28.210.77 with SMTP id j74mr14774901wmg.60.1446894291869; Sat, 07 Nov 2015 03:04:51 -0800 (PST) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id gl4sm4522981wjd.49.2015.11.07.03.04.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Nov 2015 03:04:50 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v4 5/7] emacs/show: Make the insertion of part headers overridable. Date: Sat, 7 Nov 2015 11:04:34 +0000 Message-Id: <1446894276-7814-6-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> 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: Sat, 07 Nov 2015 11:05:06 -0000 From: David Edmondson This allows callers of notmuch-show-insert-bodypart to use a `let' binding to override the default function for specifying when part headers should be inserted. --- emacs/notmuch-show.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f8184e2..f4a65cc 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -945,8 +945,16 @@ (defun notmuch-show-mime-type (part) "text/x-diff") content-type))) +;; The following variable can be overridden by let bindings. +(defvar notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p + "Specify which function decides which part headers get inserted. + +The function should take two parameters, PART and HIDE, and +should return non-NIL if a header button should be inserted for +this part.") + (defun notmuch-show-insert-header-p (part hide) - "Return non-NIL if a header button should be inserted for this part." + ;; Show all part buttons except for the first part if it is text/plain. (let ((mime-type (notmuch-show-mime-type part))) (not (and (string= mime-type "text/plain") (<= (plist-get part :id) 1))))) @@ -965,9 +973,9 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide) (> notmuch-show-max-text-part-size 0) (> (length (plist-get part :content)) notmuch-show-max-text-part-size))) (beg (point)) - ;; We omit the part button for the first (or only) part if - ;; this is text/plain, or HIDE is 'no-buttons. - (button (when (notmuch-show-insert-header-p part hide) + ;; This default header-p function omits the part button for + ;; the first (or only) part if this is text/plain. + (button (when (funcall notmuch-show-insert-header-p-function 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