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 D11E7431FBC for ; Mon, 15 Feb 2010 06:16:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.514 X-Spam-Level: X-Spam-Status: No, score=-1.514 tagged_above=-999 required=5 tests=[AWL=-0.404, BAYES_05=-1.11] autolearn=ham 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 O2iz14CxXeyz for ; Mon, 15 Feb 2010 06:16:42 -0800 (PST) Received: from mail-fx0-f224.google.com (mail-fx0-f224.google.com [209.85.220.224]) by olra.theworths.org (Postfix) with ESMTP id D29C4431FAE for ; Mon, 15 Feb 2010 06:16:41 -0800 (PST) Received: by fxm24 with SMTP id 24so5895697fxm.0 for ; Mon, 15 Feb 2010 06:16:40 -0800 (PST) Received: by 10.87.36.4 with SMTP id o4mr8968925fgj.69.1266243400843; Mon, 15 Feb 2010 06:16:40 -0800 (PST) Received: from aw.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1]) by mx.google.com with ESMTPS id d8sm13745674fga.13.2010.02.15.06.16.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 15 Feb 2010 06:16:40 -0800 (PST) Received: by aw.hh.sledj.net (Postfix, from userid 1000) id 48CE43A09B; Mon, 15 Feb 2010 14:16:22 +0000 (GMT) To: notmuch@notmuchmail.org From: David Edmondson Date: Mon, 15 Feb 2010 14:16:22 +0000 Message-ID: <87zl3afutl.fsf@aw.hh.sledj.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: [notmuch] [RFC] labelling parts 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, 15 Feb 2010 14:16:43 -0000 --=-=-= I've always been quite fond of the way that gnus labelled parts in MIME messages. Here's a start at doing the same for notmuch.el. Is this something that might be accepted upstream if I continue? Obvious next steps are: - allow the user to choose which parts have buttons (i.e perhaps not text/plain by default), - have the inserted buttons actually do something useful (toggle visibility and/or save). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-notmuch.el-Label-the-head-of-each-part.patch >From fcdbb8b3452911ce4c836547fc12519b1881e515 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Mon, 15 Feb 2010 14:13:45 +0000 Subject: [PATCH] notmuch.el: Label the head of each part. --- notmuch.el | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/notmuch.el b/notmuch.el index b4f8e12..ea74a72 100644 --- a/notmuch.el +++ b/notmuch.el @@ -128,6 +128,9 @@ remaining lines into a button.") (defvar notmuch-show-attachment-end-regexp "\fattachment}") (defvar notmuch-show-part-begin-regexp "\fpart{") (defvar notmuch-show-part-end-regexp "\fpart}") + +(defvar notmuch-show-buttonize-begin-regexp "\f\\(part\\|attachment\\){") +(defvar notmuch-show-buttonize-end-regexp "\f\\(part\\|attachment\\)}") (defvar notmuch-show-marker-regexp "\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$") (defvar notmuch-show-id-regexp "\\(id:[^ ]*\\)") @@ -650,6 +653,9 @@ which this thread was originally shown." 'help-echo "mouse-1, RET: Show message" 'face 'notmuch-message-summary-face :supertype 'notmuch-button-invisibility-toggle-type) +(define-button-type 'notmuch-button-part-toggle-type 'help-echo "mouse-1, RET: Show part" + :supertype 'notmuch-button-invisibility-toggle-type + 'face 'font-lock-keyword-face) (defun notmuch-show-citation-regexp (depth) "Build a regexp for matching citations at a given DEPTH (indent)" @@ -731,7 +737,7 @@ is what to put on the button." ))))))) (defun notmuch-show-markup-part (beg end depth) - (if (re-search-forward notmuch-show-part-begin-regexp nil t) + (if (re-search-forward notmuch-show-buttonize-begin-regexp nil t) (progn (let (mime-message mime-type) (save-excursion @@ -739,14 +745,19 @@ is what to put on the button." (setq mime-type (car (split-string (buffer-substring (match-beginning 1) (match-end 1)))))) + + (forward-line) + (insert-button (format (concat "%" (format "%d" depth) "s[ %s ]\n") "" mime-type) + :type 'notmuch-button-part-toggle-type) + (if (equal mime-type "text/html") (let ((filename (notmuch-show-get-filename))) (with-temp-buffer (insert-file-contents filename nil nil nil t) (setq mime-message (mm-dissect-buffer))))) - (forward-line) + (let ((beg (point-marker))) - (re-search-forward notmuch-show-part-end-regexp) + (re-search-forward notmuch-show-buttonize-end-regexp) (let ((end (copy-marker (match-beginning 0)))) (goto-char end) (if (not (bolp)) @@ -765,12 +776,12 @@ is what to put on the button." (if (equal mime-type "text/html") (mm-display-part mime-message)))) ) - (notmuch-show-markup-citations-region beg end depth) + (if (equal mime-type "text/plain") + (notmuch-show-markup-citations-region beg end depth)) ; Advance to the next part (if any) (so the outer loop can ; determine whether we've left the current message. - (if (re-search-forward notmuch-show-part-begin-regexp nil t) - (beginning-of-line))))) - (goto-char end)) + (if (re-search-forward notmuch-show-buttonize-begin-regexp nil t) + (beginning-of-line)))))) (goto-char end))) (defun notmuch-show-markup-parts-region (beg end depth) -- 1.6.6.1 --=-=-= dme. -- David Edmondson, http://dme.org --=-=-=--