From c76f9a7740ba5be5c1fdb41cabdf8a43aaaa4398 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 14 Feb 2016 18:39:57 +0000 Subject: [PATCH] [PATCH v5 5/7] emacs/show: Make the insertion of part headers overridable. --- 30/f85c697ee7d35844602c54040365ef97520503 | 119 ++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 30/f85c697ee7d35844602c54040365ef97520503 diff --git a/30/f85c697ee7d35844602c54040365ef97520503 b/30/f85c697ee7d35844602c54040365ef97520503 new file mode 100644 index 000000000..7d8d67a67 --- /dev/null +++ b/30/f85c697ee7d35844602c54040365ef97520503 @@ -0,0 +1,119 @@ +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 640EE6DE178F + for ; Sun, 14 Feb 2016 10:40:27 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.247 +X-Spam-Level: +X-Spam-Status: No, score=-0.247 tagged_above=-999 required=5 tests=[AWL=0.323, + 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_DNSWL_LOW=-0.7, + 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 IEdtKJPVBOAp for ; + Sun, 14 Feb 2016 10:40:25 -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 DD59F6DE17BD for + ; Sun, 14 Feb 2016 10:40:22 -0800 (PST) +Received: by mail-wm0-f68.google.com with SMTP id c200so12198520wme.0 + for ; Sun, 14 Feb 2016 10:40:22 -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=I2z6cGyLkuJQKLZmtPDG96dFYAkL+7Q/mjRueLiQRJU=; + b=XMJmzJVG5xwaUiBM7WzcsJ/ytNNjVkOOYAQBrxi9Ni7kx8vQVsdLCdHao3Q9HDNFek + RQzU8bQmPm/v1qT9FfymGkM7u19a5l8oAKWagwNINwi5YVHn3Ua+N775eXb8EBfnQxrm + FiQF7RJPseLvwF2XKlogsh+nsn+zCLv6gvYcVEArSpvezz3PfWHqYwwk2a7nIg4xiBiF + U+TKt/EMc7GXf1lBLRWlen/w4l3acG+pfYGLlx1JXdVokdc5sq8f6zBNgLgiCoLUVZTr + +2AoCTUUStjRcWMcYX4JyqRfIbPLaZhpCk4R0shoZfdJyUvsPeD9vhruEfu+0WE6qEVF + ZscQ== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=I2z6cGyLkuJQKLZmtPDG96dFYAkL+7Q/mjRueLiQRJU=; + b=CaOWukB+HZVkkFnfdmSRz87VknqPoB1D8lwvLQcGZBhHiRE4klXokiAELfB7Jm3i+T + nqTxWUTDDkksGkA3XTUSNpGMHJ4HVQlz31ydGBLH3uwuXkkKHNt3FyD4P0EiTwqH5ZU3 + T2a5TUTfw/YbtXCFxEI45YPqyjuBiV6D5KK1HBdyzLB91sHx4I87L3McH9wLZko78KMa + drxsnd/ZwZdAyzQMuvqg4hSElMOfOjHJzB9N1bAN8o/u4GDdRsvrBXIo5cRBAs+wmRk9 + si7yXy7zCdHKcConsxhHjeZmYmVCJD8xx4E4PDJpvW7YlGfQVpgqDw+N9fDge6ZRH+QG + LUFQ== +X-Gm-Message-State: + AG10YOQvwDmu3GSMQ1vue2Nwoqb5Zp/0xJM2cBC7JdLcfR5dxg4GEPAKRZsPG49xq0YqTA== +X-Received: by 10.28.126.65 with SMTP id z62mr9078028wmc.3.1455475221538; + Sun, 14 Feb 2016 10:40:21 -0800 (PST) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id a128sm12052441wmh.6.2016.02.14.10.40.20 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sun, 14 Feb 2016 10:40:21 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v5 5/7] emacs/show: Make the insertion of part headers + overridable. +Date: Sun, 14 Feb 2016 18:39:57 +0000 +Message-Id: <1455475199-32622-6-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com> +References: <1455475199-32622-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: Sun, 14 Feb 2016 18:40:27 -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 | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index f0bbff0..5654d11 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -943,8 +943,15 @@ will return nil if the CID is unknown or cannot be retrieved." + "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") +@@ -964,7 +971,9 @@ is t, hide the part initially and show the button." + (> notmuch-show-max-text-part-size 0) + (> (length (plist-get part :content)) notmuch-show-max-text-part-size))) + (beg (point)) +- (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. +-- +2.1.4 + -- 2.26.2