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 3BA34431FB6 for ; Fri, 20 Jan 2012 02:34:24 -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 DLkcjqZ9UDea for ; Fri, 20 Jan 2012 02:34:23 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 84BE1431FAE for ; Fri, 20 Jan 2012 02:34:23 -0800 (PST) Received: by wgbdt12 with SMTP id dt12so347349wgb.2 for ; Fri, 20 Jan 2012 02:34:22 -0800 (PST) Received: by 10.180.108.232 with SMTP id hn8mr24707629wib.16.1327055662299; Fri, 20 Jan 2012 02:34:22 -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 ho4sm2469052wib.3.2012.01.20.02.34.20 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Jan 2012 02:34:21 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 524E2A0950; Fri, 20 Jan 2012 09:43:33 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 3/3] emacs: Optionally hide some part headers. Date: Fri, 20 Jan 2012 09:43:32 +0000 Message-Id: <1327052612-1040-3-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327052612-1040-1-git-send-email-dme@dme.org> References: <1327052612-1040-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: Fri, 20 Jan 2012 10:34:24 -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 | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 97e2a15..fa826f7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -110,6 +110,12 @@ indentation." :group 'notmuch :type 'boolean) +(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 @@ -285,23 +291,30 @@ message at DEPTH in the current thread." 'follow-link t 'face 'message-mml) +(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 - 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 + button-parameters) + (insert "\n"))) ;; Functions handling particular MIME parts. -- 1.7.8.3