[notmuch] [RFC] labelling parts

2010-02-15 Thread David Edmondson
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).

-- next part --
A non-text attachment was scrubbed...
Name: 0001-notmuch.el-Label-the-head-of-each-part.patch
Type: text/x-diff
Size: 3585 bytes
Desc: not available
URL: 

-- next part --

dme.
-- 
David Edmondson, http://dme.org


[notmuch] [RFC] labelling parts

2010-02-15 Thread David Edmondson
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).

From fcdbb8b3452911ce4c836547fc12519b1881e515 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Mon, 15 Feb 2010 14:13:45 +
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
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch