From: Michal Nazarewicz
With this change, emacs users can use notmuch-message-headers
variable to configure notmuch-show display Bcc header.
---
notmuch-show.c |7 +++
test/json|8
test/test-lib.sh |5 +
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/notmuch-show.c b/notmuch-show.c
index 3556293..0b7abf1 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -233,6 +233,13 @@ format_headers_json (sprinter_t *sp, GMimeMessage *message,
sp->string (sp, recipients_string);
}
+recipients = g_mime_message_get_recipients (message,
GMIME_RECIPIENT_TYPE_BCC);
+recipients_string = internet_address_list_to_string (recipients, 0);
+if (recipients_string) {
+ sp->map_key (sp, "Bcc");
+ sp->string (sp, recipients_string);
+}
+
if (reply) {
sp->map_key (sp, "In-reply-to");
sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message),
"In-reply-to"));
diff --git a/test/json b/test/json
index ac8fa8e..40d0ba3 100755
--- a/test/json
+++ b/test/json
@@ -3,18 +3,18 @@ test_description="--format=json output"
. ./test-lib.sh
test_begin_subtest "Show message: json"
-add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000
12:00:00 -\"" "[body]=\"json-show-message\""
+add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\""
"[body]=\"json-show-message\""
output=$(notmuch show --format=json "json-show-message")
-test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan
2000 12:00:00 +\"}, \"body\": [{\"id\": 1, \"content-type\":
\"text/plain\", \"content\": \"json-show-message\n\"}]}, ["
+test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Bcc\":
\"test_suite+...@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00
+\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\":
\"json-show-message\n\"}]}, ["
# This should be the same output as above.
test_begin_subtest "Show message: json --body=true"
output=$(notmuch show --format=json --body=true "json-show-message")
-test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan
2000 12:00:00 +\"}, \"body\": [{\"id\": 1, \"content-type\":
\"text/plain\", \"content\": \"json-show-message\n\"}]}, ["
+test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Bcc\":
\"test_suite+...@notmuchmail.org\",\"Date\": \"Sat, 01 Jan 2000 12:00:00
+\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\":
\"json-show-message\n\"}]}, ["
test_begin_subtest "Show message: json --body=false"
output=$(notmuch show --format=json --body=false "json-show-message")
-test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan
2000 12:00:00 +\"}}, ["
+test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\":
true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\",
\"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\":
[\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\",
\"From\": \"Notmuch Test Suite \", \"To\":
\"Notmuch Test Suite \", \"Bcc\":
\"test_suite+...@notmuchmail.org\",\"Date\": \"Sat, 01 Jan 2000 12:00:00
+\"}}, ["
test_begin_subtest "Search message: json"
add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000
12:00