From 341290e6b3081e341b580f41cb16a568752f450f Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Mon, 6 Feb 2012 15:39:07 +0000 Subject: [PATCH] [PATCH v3 2/3] emacs: Optionally hide some part headers. --- a0/8da7ceed7ecc9d4262903348bdc96517dac9ab | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 a0/8da7ceed7ecc9d4262903348bdc96517dac9ab diff --git a/a0/8da7ceed7ecc9d4262903348bdc96517dac9ab b/a0/8da7ceed7ecc9d4262903348bdc96517dac9ab new file mode 100644 index 000000000..b4485a174 --- /dev/null +++ b/a0/8da7ceed7ecc9d4262903348bdc96517dac9ab @@ -0,0 +1,128 @@ +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 798E8431FCB + for ; Mon, 6 Feb 2012 07:39:19 -0800 (PST) +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 6urgHWwPcOl7 for ; + Mon, 6 Feb 2012 07:39:16 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id ECFD9431FAF + for ; Mon, 6 Feb 2012 07:39:15 -0800 (PST) +Received: by wibhi8 with SMTP id hi8so4927745wib.26 + for ; Mon, 06 Feb 2012 07:39:14 -0800 (PST) +Received: by 10.180.103.68 with SMTP id fu4mr24991109wib.7.1328542754254; + Mon, 06 Feb 2012 07:39:14 -0800 (PST) +Received: from hotblack-desiato.hh.sledj.net + (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) + by mx.google.com with ESMTPS id p10sm26449625wic.0.2012.02.06.07.39.10 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 06 Feb 2012 07:39:11 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id 52146A0E82; Mon, 6 Feb 2012 15:39:09 +0000 (GMT) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH v3 2/3] emacs: Optionally hide some part headers. +Date: Mon, 6 Feb 2012 15:39:07 +0000 +Message-Id: <1328542748-19530-4-git-send-email-dme@dme.org> +X-Mailer: git-send-email 1.7.8.3 +In-Reply-To: <1328542748-19530-1-git-send-email-dme@dme.org> +References: <1327052612-1040-1-git-send-email-dme@dme.org> + <1328542748-19530-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, 06 Feb 2012 15:39:19 -0000 + +Add a regexp, `notmuch-show-part-headers-hidden' and if the +content-type of a part matches, don't show the part header. +--- + emacs/notmuch-show.el | 43 ++++++++++++++++++++++++++++--------------- + 1 files changed, 28 insertions(+), 15 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 079d7cb..ce79762 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -125,6 +125,12 @@ indentation." + (const :tag "View interactively" + notmuch-show-interactively-view-part))) + ++(defcustom notmuch-show-part-headers-hidden nil ++ "Headers for parts whose content-type matches this regexp will ++not be shown." ++ :group 'notmuch ++ :type 'regexp) ++ + (defmacro with-current-notmuch-show-message (&rest body) + "Evaluate body with current buffer set to the text of current message" + `(save-excursion +@@ -397,24 +403,31 @@ message at DEPTH in the current thread." + "Submap for button commands") + (fset 'notmuch-show-part-button-map notmuch-show-part-button-map) + ++(defun notmuch-show-hidden-part-header (content-type) ++ "Return non-nil if a part header should be hidden for ++CONTENT-TYPE parts." ++ (and notmuch-show-part-headers-hidden ++ (string-match notmuch-show-part-headers-hidden content-type))) ++ + (defun notmuch-show-insert-part-header (nth content-type declared-type + &optional name comment + &rest button-parameters) +- (apply #'insert-button +- (concat "[ " +- (if name (concat name ": ") "") +- declared-type +- (if (not (string-equal declared-type content-type)) +- (concat " (as " content-type ")") +- "") +- (or comment "") +- " ]") +- :type 'notmuch-show-part-button-type +- :notmuch-part nth +- :notmuch-filename name +- :notmuch-content-type content-type +- button-parameters) +- (insert "\n")) ++ (unless (notmuch-show-hidden-part-header content-type) ++ (apply #'insert-button ++ (concat "[ " ++ (if name (concat name ": ") "") ++ declared-type ++ (if (not (string-equal declared-type content-type)) ++ (concat " (as " content-type ")") ++ "") ++ (or comment "") ++ " ]") ++ :type 'notmuch-show-part-button-type ++ :notmuch-part nth ++ :notmuch-filename name ++ :notmuch-content-type content-type ++ button-parameters) ++ (insert "\n"))) + + ;; Functions handling particular MIME parts. + +-- +1.7.8.3 + -- 2.26.2