* Updated notmuch-show-get-* functions
[not found] <id:1260021951-3022-1-git-send-email-david@tethera.net>
@ 2010-02-12 2:34 ` david
2010-02-12 2:34 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields david
0 siblings, 1 reply; 4+ messages in thread
From: david @ 2010-02-12 2:34 UTC (permalink / raw)
To: notmuch
I have rebased the patch for notmuch-show-get-header,and added functions
for each of the header fields (I think) parsed by mailheader.el.
There is a corresponding updated stash patch series that uses these functions to provide
convenient access to various fields, even if not currently displayed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.
2010-02-12 2:34 ` Updated notmuch-show-get-* functions david
@ 2010-02-12 2:34 ` david
2010-02-12 2:34 ` [PATCH 2/2] Add functions notmuch-show-get-(bcc, cc, date, from, subject, to) to return the corresponding header field for the current message as a string. These are thin wrappers around notmuch-show-get-header, which means they each cause a full parse of the RFC822 header. The main idea is to fix an api david
2010-02-20 20:14 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields Carl Worth
0 siblings, 2 replies; 4+ messages in thread
From: david @ 2010-02-12 2:34 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
From: David Bremner <bremner@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Add functions notmuch-show-get-(bcc, cc, date, from, subject, to) to return the corresponding header field for the current message as a string. These are thin wrappers around notmuch-show-get-header, which means they each cause a full parse of the RFC822 header. The main idea is to fix an api.
2010-02-12 2:34 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields david
@ 2010-02-12 2:34 ` david
2010-02-20 20:14 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields Carl Worth
1 sibling, 0 replies; 4+ messages in thread
From: david @ 2010-02-12 2:34 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
From: David Bremner <bremner@unb.ca>
---
notmuch.el | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index c96fd94..d2a3b1b 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -225,6 +225,38 @@ 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-bcc ()
+ "Return To address of current message"
+ (notmuch-show-get-header-field 'bcc))
+
+(defun notmuch-show-get-cc ()
+ "Return To address of current message"
+ (notmuch-show-get-header-field 'cc))
+
+(defun notmuch-show-get-date ()
+ "Return To address of current message"
+ (notmuch-show-get-header-field 'date))
+
+(defun notmuch-show-get-from ()
+ "Return From address of current message"
+ (notmuch-show-get-header-field 'from))
+
+(defun notmuch-show-get-subject ()
+ "Return subject of current message"
+ (notmuch-show-get-header-field 'subject))
+
+(defun notmuch-show-get-to ()
+ "Return To address of current message"
+ (notmuch-show-get-header-field 'to))
+
+(defun notmuch-show-get-header-field (name)
+ "Retrieve the header field NAME from the current message.
+NAME should be a symbol, in lower case, as returned by
+mail-header-extract-no-properties"
+ (let* ((result (assoc name (notmuch-show-get-header)))
+ (val (and result (cdr result))))
+ val))
+
(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
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields.
2010-02-12 2:34 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields david
2010-02-12 2:34 ` [PATCH 2/2] Add functions notmuch-show-get-(bcc, cc, date, from, subject, to) to return the corresponding header field for the current message as a string. These are thin wrappers around notmuch-show-get-header, which means they each cause a full parse of the RFC822 header. The main idea is to fix an api david
@ 2010-02-20 20:14 ` Carl Worth
1 sibling, 0 replies; 4+ messages in thread
From: Carl Worth @ 2010-02-20 20:14 UTC (permalink / raw)
To: david, notmuch; +Cc: David Bremner
[-- Attachment #1: Type: text/plain, Size: 521 bytes --]
On Thu, 11 Feb 2010 22:34:31 -0400, david@tethera.net wrote:
> From: David Bremner <bremner@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
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-20 20:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <id:1260021951-3022-1-git-send-email-david@tethera.net>
2010-02-12 2:34 ` Updated notmuch-show-get-* functions david
2010-02-12 2:34 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields david
2010-02-12 2:34 ` [PATCH 2/2] Add functions notmuch-show-get-(bcc, cc, date, from, subject, to) to return the corresponding header field for the current message as a string. These are thin wrappers around notmuch-show-get-header, which means they each cause a full parse of the RFC822 header. The main idea is to fix an api david
2010-02-20 20:14 ` [PATCH 1/2] notmuch-show-get-header: new function; return alist of parsed header fields Carl Worth
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).