Re: [RFC PATCH 5/5] cli: add support for deduplicating based on case insensitive...
[notmuch-archives.git] / 4d / 8ed6451b13bd60472e102376631db83069ef72
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 74555431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Dec 2009 06:06:10 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id BcKAv7cA6RuA for <notmuch@notmuchmail.org>;\r
11         Sat,  5 Dec 2009 06:06:09 -0800 (PST)\r
12 Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57])\r
13         by olra.theworths.org (Postfix) with ESMTP id C6EC4431FAE\r
14         for <notmuch@notmuchmail.org>; Sat,  5 Dec 2009 06:06:09 -0800 (PST)\r
15 Received: from\r
16         fctnnbsc30w-142167182194.pppoe-dynamic.high-speed.nb.bellaliant.net\r
17         ([142.167.182.194] helo=localhost)\r
18         by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32)\r
19         (Exim 4.69) (envelope-from <bremner@pivot.cs.unb.ca>)\r
20         id 1NGvGy-0004tL-Qu; Sat, 05 Dec 2009 10:06:09 -0400\r
21 Received: from bremner by localhost with local (Exim 4.69)\r
22         (envelope-from <bremner@pivot.cs.unb.ca>)\r
23         id 1NGvGt-0000nT-Bf; Sat, 05 Dec 2009 10:06:03 -0400\r
24 From: David Bremner <david@tethera.net>\r
25 To: notmuch@notmuchmail.org\r
26 Date: Sat,  5 Dec 2009 10:05:51 -0400\r
27 Message-Id: <1260021951-3022-1-git-send-email-david@tethera.net>\r
28 X-Mailer: git-send-email 1.6.5.3\r
29 In-Reply-To: <1259979997-31544-1-git-send-email-david@tethera.net>\r
30 References: <1259979997-31544-1-git-send-email-david@tethera.net>\r
31 X-Sender-Verified: bremner@pivot.cs.unb.ca\r
32 Subject: [notmuch] [PATCH] notmuch-show-get-header: new function;\r
33         return alist of parsed header fields.\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.12\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38         <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 05 Dec 2009 14:06:10 -0000\r
47 \r
48 This function parses the displayed message to recover header\r
49 fields. It uses mailheader.el to do the actual header parsing, after\r
50 preprocessing to remove indentation.  It relies on the variables\r
51 notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,\r
52 and notmuch-show-message-end-regexp.\r
53 ---\r
54 \r
55 This is another patch needed for org-mode links. Really I just need\r
56 some way to get the author and subject of the current message in\r
57 notmuch-show-mode.  It seems like a generally useful function,\r
58 although of course it would be more efficient to cache these headers\r
59 somewhere if the function is being invoked many times.\r
60 \r
61  notmuch.el |   24 ++++++++++++++++++++++++\r
62  1 files changed, 24 insertions(+), 0 deletions(-)\r
63 \r
64 diff --git a/notmuch.el b/notmuch.el\r
65 index f7048d5..cf472f7 100644\r
66 --- a/notmuch.el\r
67 +++ b/notmuch.el\r
68 @@ -203,6 +203,30 @@ Unlike builtin `previous-line' this version accepts no arguments."\r
69      (re-search-forward notmuch-show-tags-regexp)\r
70      (split-string (buffer-substring (match-beginning 1) (match-end 1)))))\r
71  \r
72 +(defun notmuch-show-get-header ()\r
73 +  "Retrieve and parse the header from the current message. Returns an alist with of (header . value) \r
74 +where header is a symbol and value is a string.  The summary from notmuch-show is returned as the \r
75 +pseudoheader summary"\r
76 +  (require 'mailheader)\r
77 +  (save-excursion\r
78 +    (beginning-of-line)\r
79 +    (if (not (looking-at notmuch-show-message-begin-regexp))\r
80 +       (re-search-backward notmuch-show-message-begin-regexp))\r
81 +    (re-search-forward (concat notmuch-show-header-begin-regexp "\n[[:space:]]*\\(.*\\)\n"))\r
82 +    (let* ((summary (buffer-substring-no-properties (match-beginning 1) (match-end 1)))\r
83 +         (beg (point)))\r
84 +      (re-search-forward notmuch-show-header-end-regexp)\r
85 +      (let ((text (buffer-substring beg (match-beginning 0))))\r
86 +       (with-temp-buffer\r
87 +         (insert text)\r
88 +         (goto-char (point-min))\r
89 +         (while (looking-at "\\([[:space:]]*\\)[A-Za-z][-A-Za-z0-9]*:")\r
90 +           (delete-region (match-beginning 1) (match-end 1))\r
91 +           (forward-line)\r
92 +           )\r
93 +         (goto-char (point-min))\r
94 +         (cons (cons 'summary summary) (mail-header-extract-no-properties)))))))\r
95 +  \r
96  (defun notmuch-show-add-tag (&rest toadd)\r
97    "Add a tag to the current message."\r
98    (interactive\r
99 -- \r
100 1.6.5.3\r
101 \r