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 35C136DE14FD for ; Tue, 9 Feb 2016 12:32:20 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.087 X-Spam-Level: X-Spam-Status: No, score=-0.087 tagged_above=-999 required=5 tests=[AWL=-0.020, 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 jy1j5TzyHquY for ; Tue, 9 Feb 2016 12:32:18 -0800 (PST) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 0B6D96DE01D3 for ; Tue, 9 Feb 2016 12:32:18 -0800 (PST) Received: by mail-wm0-f68.google.com with SMTP id p63so59099wmp.1 for ; Tue, 09 Feb 2016 12:32:17 -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=tl4jJGpsyLPvEb1hWmKE0UmrCBIQbnCFKR+LaYlLLnE=; b=V6b2thQNi43sbBO9DwWNXJwtLe5yKS89PgbFYu4QFzD9bDWCyNEa2ptOHyo29f1zxG a8Cplm0e1OIY0WRbuTJQeP9NHhgQ+pmFfp67fuyvubegSAGNiyJy4vSuTeEcSrRz1hKm yvmcArvnwMBEoYxzUuqWH5tkhsJ1oTE5G18UGuxgbwMHXH+L03Ee5z8UVgj3/3E53VV4 PEwZNkMiocuj2/on2KXzPPgMrZvTxoOvEyV3uMlanFADWjVyKxoaPrkb2r8Q0nWJZi2C 0lpFea2h9aAWaX7sMUI7s8QsmAb1ABj1vqmiP01u7+4acT40qQeZYUtxEeN1dZLYjD6h uSMQ== 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=tl4jJGpsyLPvEb1hWmKE0UmrCBIQbnCFKR+LaYlLLnE=; b=eZermYubUxb9qN5VT6K8Jq2RsmYme+CxXwqjIJXl/nFiOf/pYCoqklLula2b7zsZ+m GxFVrIon1P7DMndAT7T5AP7crh0/0kCUEq5bsu3e2uHJ1Is9UXTRmTL3nC42wln15Pd3 GBjPHeYCqMFYrAgN5Z913OAWQKKqQuRc/q2ipgLoSxRzxsqrqgJ0kDVjt6J6EeOAxOfO IUrXNVl1k0X9EO+o/G66v4XbkhkfEF9zsJrZUWKGzdTehksylPowDlQazIvXn5JczA4E X9r7qTK+RcJw5QwHERp1cy40XotJk3wEd2ZXsKk7myCmWy7rVroXRokWWVRGBoacZDJg 886w== X-Gm-Message-State: AG10YOTugjPIhZrOu0lV/KwhkPKOXu4DZVmId0x5TeNobLZ3Ds4wkLCrH8XaLfUbY4wInA== X-Received: by 10.194.87.201 with SMTP id ba9mr35816752wjb.128.1455049936716; Tue, 09 Feb 2016 12:32:16 -0800 (PST) Received: from disaster-area.hh.sledj.net ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) by smtp.gmail.com with ESMTPSA id bg1sm36397861wjc.27.2016.02.09.12.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 12:32:15 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 33ba720f; Tue, 9 Feb 2016 20:32:13 +0000 (UTC) To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v4 5/7] emacs/show: Make the insertion of part headers overridable. In-Reply-To: <1446894276-7814-6-git-send-email-markwalters1009@gmail.com> References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> <1446894276-7814-6-git-send-email-markwalters1009@gmail.com> From: David Edmondson Date: Tue, 09 Feb 2016 20:32:13 +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:32:20 -0000 On Sat, Nov 07 2015, Mark Walters wrote: > 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. Looks fine. > --- > 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