[notmuch] [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.

2010-02-20 Thread Carl Worth
On Thu, 11 Feb 2010 22:34:31 -0400, david at tethera.net wrote:
> From: David Bremner 
> 
> This function parses the displayed message to recover header
> fields. It uses mailheader.el to do the actual header parsing, after
> preprocessing to remove indentation.  It relies on the variables
> notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
> and notmuch-show-message-end-regexp.

Thanks, David.

I've applied this now, (amended to not add any trailing whitespace).

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.

2010-02-20 Thread Carl Worth
On Thu, 11 Feb 2010 22:34:31 -0400, da...@tethera.net wrote:
 From: David Bremner brem...@unb.ca
 
 This function parses the displayed message to recover header
 fields. It uses mailheader.el to do the actual header parsing, after
 preprocessing to remove indentation.  It relies on the variables
 notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
 and notmuch-show-message-end-regexp.

Thanks, David.

I've applied this now, (amended to not add any trailing whitespace).

-Carl


pgpq791uNZFmj.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.

2010-02-11 Thread da...@tethera.net
From: David Bremner 

This function parses the displayed message to recover header
fields. It uses mailheader.el to do the actual header parsing, after
preprocessing to remove indentation.  It relies on the variables
notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
and notmuch-show-message-end-regexp.
---
 notmuch.el |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index c0bb552..c96fd94 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -225,6 +225,30 @@ Unlike builtin `previous-line' this version accepts no 
arguments."
 (re-search-forward notmuch-show-tags-regexp)
 (split-string (buffer-substring (match-beginning 1) (match-end 1)

+(defun notmuch-show-get-header ()
+  "Retrieve and parse the header from the current message. Returns an alist 
with of (header . value) 
+where header is a symbol and value is a string.  The summary from notmuch-show 
is returned as the 
+pseudoheader summary"
+  (require 'mailheader)
+  (save-excursion
+(beginning-of-line)
+(if (not (looking-at notmuch-show-message-begin-regexp))
+   (re-search-backward notmuch-show-message-begin-regexp))
+(re-search-forward (concat notmuch-show-header-begin-regexp 
"\n[[:space:]]*\\(.*\\)\n"))
+(let* ((summary (buffer-substring-no-properties (match-beginning 1) 
(match-end 1)))
+ (beg (point)))
+  (re-search-forward notmuch-show-header-end-regexp)
+  (let ((text (buffer-substring beg (match-beginning 0
+   (with-temp-buffer
+ (insert text)
+ (goto-char (point-min))
+ (while (looking-at "\\([[:space:]]*\\)[A-Za-z][-A-Za-z0-9]*:")
+   (delete-region (match-beginning 1) (match-end 1))
+   (forward-line)
+   )
+ (goto-char (point-min))
+ (cons (cons 'summary summary) 
(mail-header-extract-no-properties)))
+  
 (defun notmuch-show-add-tag ( toadd)
   "Add a tag to the current message."
   (interactive
-- 
1.6.5



[notmuch] [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.

2010-02-11 Thread david
From: David Bremner brem...@unb.ca

This function parses the displayed message to recover header
fields. It uses mailheader.el to do the actual header parsing, after
preprocessing to remove indentation.  It relies on the variables
notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
and notmuch-show-message-end-regexp.
---
 notmuch.el |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index c0bb552..c96fd94 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -225,6 +225,30 @@ Unlike builtin `previous-line' this version accepts no 
arguments.
 (re-search-forward notmuch-show-tags-regexp)
 (split-string (buffer-substring (match-beginning 1) (match-end 1)
 
+(defun notmuch-show-get-header ()
+  Retrieve and parse the header from the current message. Returns an alist 
with of (header . value) 
+where header is a symbol and value is a string.  The summary from notmuch-show 
is returned as the 
+pseudoheader summary
+  (require 'mailheader)
+  (save-excursion
+(beginning-of-line)
+(if (not (looking-at notmuch-show-message-begin-regexp))
+   (re-search-backward notmuch-show-message-begin-regexp))
+(re-search-forward (concat notmuch-show-header-begin-regexp 
\n[[:space:]]*\\(.*\\)\n))
+(let* ((summary (buffer-substring-no-properties (match-beginning 1) 
(match-end 1)))
+ (beg (point)))
+  (re-search-forward notmuch-show-header-end-regexp)
+  (let ((text (buffer-substring beg (match-beginning 0
+   (with-temp-buffer
+ (insert text)
+ (goto-char (point-min))
+ (while (looking-at \\([[:space:]]*\\)[A-Za-z][-A-Za-z0-9]*:)
+   (delete-region (match-beginning 1) (match-end 1))
+   (forward-line)
+   )
+ (goto-char (point-min))
+ (cons (cons 'summary summary) 
(mail-header-extract-no-properties)))
+  
 (defun notmuch-show-add-tag (rest toadd)
   Add a tag to the current message.
   (interactive
-- 
1.6.5

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch