From: Peter Wang <novalazy@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] show: add In-reply-to, References fields to structured formats
Date: Sun, 12 Jan 2014 16:00:00 +1100 [thread overview]
Message-ID: <1389502800-9237-1-git-send-email-novalazy@gmail.com> (raw)
This is useful when 'show' is used to retrieve a draft message
which is in reply to another message.
---
devel/schemata | 9 ++++++++-
notmuch-show.c | 16 ++++++++++++----
test/thread-replies | 7 +++++++
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/devel/schemata b/devel/schemata
index 41dc4a6..dd41217 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -14,7 +14,7 @@ are interleaved. Keys are printed as keywords (symbols preceded by a
colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
nil, true as t and false as nil.
-This is version 2 of the structured output format.
+This is version 3 of the structured output format.
Version history
---------------
@@ -26,6 +26,9 @@ v1
v2
- Added the thread_summary.query field.
+v3
+- Added headers.in-reply-to and headers.references fields.
+
Common non-terminals
--------------------
@@ -105,6 +108,10 @@ headers = {
Cc?: string,
Bcc?: string,
Reply-To?: string,
+ # Added in schema version 3.
+ In-reply-to?: string,
+ # Added in schema version 3.
+ References?: string,
Date: string
}
diff --git a/notmuch-show.c b/notmuch-show.c
index c07f887..774ba44 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -222,6 +222,8 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
InternetAddressList *recipients;
const char *recipients_string;
const char *reply_to_string;
+ const char *in_reply_to_string;
+ const char *references_string;
sp->begin_map (sp);
@@ -258,13 +260,19 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
sp->string (sp, reply_to_string);
}
- if (reply) {
+ in_reply_to_string = g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to");
+ if (in_reply_to_string || reply) {
sp->map_key (sp, "In-reply-to");
- sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "In-reply-to"));
+ sp->string (sp, in_reply_to_string);
+ }
+ references_string = g_mime_object_get_header (GMIME_OBJECT (message), "References");
+ if (references_string || reply) {
sp->map_key (sp, "References");
- sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
- } else {
+ sp->string (sp, references_string);
+ }
+
+ if (! reply) {
sp->map_key (sp, "Date");
sp->string (sp, g_mime_message_get_date_as_string (message));
}
diff --git a/test/thread-replies b/test/thread-replies
index eeb70d0..9d4b379 100755
--- a/test/thread-replies
+++ b/test/thread-replies
@@ -39,6 +39,8 @@ expected='[[[{"id": "foo@one.com",
"tags": ["inbox", "unread"], "headers": {"Subject": "Re: one",
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
+ "In-reply-to": "mumble",
+ "References": "<foo@one.com>",
"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
"body": [{"id": 1, "content-type": "text/plain",
"content": "This is just a test message (#2)\n"}]}, []]]]]]'
@@ -68,6 +70,8 @@ expected='[[[{"id": "foo@two.com",
"headers": {"Subject": "Re: two",
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
+ "In-reply-to": "<bar@baz.com>",
+ "References": "<foo@two.com>",
"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
"body": [{"id": 1,
"content-type": "text/plain", "content": "This is just a test message (#4)\n"}]},
@@ -95,6 +99,7 @@ expected='[[[{"id": "foo@three.com", "match": true, "excluded": false,
"headers": {"Subject": "Re: three",
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
+ "In-reply-to": "<foo@three.com>",
"Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
"content-type": "text/plain", "content": "This is just a test message (#6)\n"}]},
[]]]]]]'
@@ -124,6 +129,8 @@ expected='[[[{"id": "foo@four.com", "match": true, "excluded": false,
"headers": {"Subject": "neither",
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
+ "In-reply-to": "<baz@four.com>",
+ "References": "<baz@four.com> <foo@four.com>",
"Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
"content-type": "text/plain", "content": "This is just a test message (#9)\n"}]},
[]]]]], [[{"id": "bar@four.com", "match": true, "excluded": false,
--
1.8.4
next reply other threads:[~2014-01-12 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-12 5:00 Peter Wang [this message]
2014-01-12 15:31 ` [PATCH] show: add In-reply-to, References fields to structured formats Jani Nikula
2014-01-12 21:08 ` Peter Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389502800-9237-1-git-send-email-novalazy@gmail.com \
--to=novalazy@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).