Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 27 / 6bd3fed794bf98ab2494c924aeb377614f21ae
1 Return-Path: <bremner@pivot.cs.unb.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 7B7D5431FBD\r
6         for <notmuch@notmuchmail.org>; Thu, 11 Feb 2010 18:37:48 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.948\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.948 tagged_above=-999 required=5 tests=[AWL=0.651,\r
12         BAYES_00=-2.599] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id twizglcairmR for <notmuch@notmuchmail.org>;\r
16         Thu, 11 Feb 2010 18:37:47 -0800 (PST)\r
17 Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57])\r
18         by olra.theworths.org (Postfix) with ESMTP id D03F0431FBC\r
19         for <notmuch@notmuchmail.org>; Thu, 11 Feb 2010 18:37:47 -0800 (PST)\r
20 Received: from\r
21         fctnnbsc30w-142167166109.pppoe-dynamic.high-speed.nb.bellaliant.net\r
22         ([142.167.166.109] helo=rocinante.cs.unb.ca)\r
23         by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32)\r
24         (Exim 4.69) (envelope-from <bremner@pivot.cs.unb.ca>)\r
25         id 1NflPf-0002KW-Ez; Thu, 11 Feb 2010 22:37:47 -0400\r
26 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.71)\r
27         (envelope-from <bremner@rocinante.cs.unb.ca>)\r
28         id 1NflMy-0007uN-Cf; Thu, 11 Feb 2010 22:35:00 -0400\r
29 From: david@tethera.net\r
30 To: notmuch@notmuchmail.org\r
31 Date: Thu, 11 Feb 2010 22:34:31 -0400\r
32 Message-Id: <1265942072-30247-2-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 1.6.5\r
34 In-Reply-To: <1265942072-30247-1-git-send-email-david@tethera.net>\r
35 References: <id:1260021951-3022-1-git-send-email-david@tethera.net>\r
36         <1265942072-30247-1-git-send-email-david@tethera.net>\r
37 X-Sender-Verified: bremner@pivot.cs.unb.ca\r
38 Cc: David Bremner <bremner@unb.ca>\r
39 Subject: [notmuch] [PATCH 1/2] notmuch-show-get-header: new function;\r
40         return alist of parsed header fields.\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Fri, 12 Feb 2010 02:37:48 -0000\r
54 \r
55 From: David Bremner <bremner@unb.ca>\r
56 \r
57 This function parses the displayed message to recover header\r
58 fields. It uses mailheader.el to do the actual header parsing, after\r
59 preprocessing to remove indentation.  It relies on the variables\r
60 notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,\r
61 and notmuch-show-message-end-regexp.\r
62 ---\r
63  notmuch.el |   24 ++++++++++++++++++++++++\r
64  1 files changed, 24 insertions(+), 0 deletions(-)\r
65 \r
66 diff --git a/notmuch.el b/notmuch.el\r
67 index c0bb552..c96fd94 100644\r
68 --- a/notmuch.el\r
69 +++ b/notmuch.el\r
70 @@ -225,6 +225,30 @@ Unlike builtin `previous-line' this version accepts no arguments."\r
71      (re-search-forward notmuch-show-tags-regexp)\r
72      (split-string (buffer-substring (match-beginning 1) (match-end 1)))))\r
73  \r
74 +(defun notmuch-show-get-header ()\r
75 +  "Retrieve and parse the header from the current message. Returns an alist with of (header . value) \r
76 +where header is a symbol and value is a string.  The summary from notmuch-show is returned as the \r
77 +pseudoheader summary"\r
78 +  (require 'mailheader)\r
79 +  (save-excursion\r
80 +    (beginning-of-line)\r
81 +    (if (not (looking-at notmuch-show-message-begin-regexp))\r
82 +       (re-search-backward notmuch-show-message-begin-regexp))\r
83 +    (re-search-forward (concat notmuch-show-header-begin-regexp "\n[[:space:]]*\\(.*\\)\n"))\r
84 +    (let* ((summary (buffer-substring-no-properties (match-beginning 1) (match-end 1)))\r
85 +         (beg (point)))\r
86 +      (re-search-forward notmuch-show-header-end-regexp)\r
87 +      (let ((text (buffer-substring beg (match-beginning 0))))\r
88 +       (with-temp-buffer\r
89 +         (insert text)\r
90 +         (goto-char (point-min))\r
91 +         (while (looking-at "\\([[:space:]]*\\)[A-Za-z][-A-Za-z0-9]*:")\r
92 +           (delete-region (match-beginning 1) (match-end 1))\r
93 +           (forward-line)\r
94 +           )\r
95 +         (goto-char (point-min))\r
96 +         (cons (cons 'summary summary) (mail-header-extract-no-properties)))))))\r
97 +  \r
98  (defun notmuch-show-add-tag (&rest toadd)\r
99    "Add a tag to the current message."\r
100    (interactive\r
101 -- \r
102 1.6.5\r
103 \r