From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3DB1642119F for ; Tue, 24 Jan 2012 04:54:01 -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 fOzd960qRPN6 for ; Tue, 24 Jan 2012 04:54:00 -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 7113F429E21 for ; Tue, 24 Jan 2012 04:54:00 -0800 (PST) Received: by wibhi8 with SMTP id hi8so1525144wib.26 for ; Tue, 24 Jan 2012 04:53:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.101.164 with SMTP id fh4mr4134455wib.0.1327409639186; Tue, 24 Jan 2012 04:53:59 -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 cb8sm14129215wib.0.2012.01.24.04.53.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jan 2012 04:53:57 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id EB2239FD49; Tue, 24 Jan 2012 12:53:55 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 2/3] emacs: Optionally hide some part headers. Date: Tue, 24 Jan 2012 12:53:39 +0000 Message-Id: <1327409620-10133-3-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327409620-10133-1-git-send-email-dme@dme.org> References: <1327052612-1040-1-git-send-email-dme@dme.org> <1327409620-10133-1-git-send-email-dme@dme.org> X-Gm-Message-State: ALoCoQmDSnRfr03Zp3F56tZ0zBiate2jW/Y67HcgPpG2c/newHoswBb6tf7xsUnD06x91FYpo/me 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: Tue, 24 Jan 2012 12:54:01 -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 d0e0d38..a0a2873 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -123,6 +123,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 @@ -355,24 +361,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