Re: [PATCH 08/20] cli/show: emit headers after emitting body

2018-06-15 Thread David Bremner
Daniel Kahn Gillmor  writes:

>  test_begin_subtest "Show message: sexp"
>  add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
> 12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
> "[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
> "[body]=\"sexp-show-message\""
>  output=$(notmuch show --format=sexp "sexp-show-message")
> -test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded 
> nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
> \"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject 
> \"sexp-show-subject\" :From \"Notmuch Test Suite 
> \" :To \"Notmuch Test Suite 
> \" :Bcc \"test_suite+...@notmuchmail.org\" 
> :Reply-To \"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 
> 12:00:00 +\") :body ((:id 1 :content-type \"text/plain\" :content 
> \"sexp-show-message\n\"))) ("
> +test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded 
> nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
> \"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
> \"text/plain\" :content \"sexp-show-message\n\")) :headers (:Subject 
> \"sexp-show-subject\" :From \"Notmuch Test Suite 
> \" :To \"Notmuch Test Suite 
> \" :Bcc \"test_suite+...@notmuchmail.org\" 
> :Reply-To \"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 
> 12:00:00 +\")) ("

It would be cool if we could canonicalize (sort) these s-expressions,
but I didn't see a nice / easy way to do that. Elisp-wizards feel free
to jump in here...

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 08/20] cli/show: emit headers after emitting body

2018-05-10 Thread Daniel Kahn Gillmor
This paves the way for emitting protected headers after verification
and decryption, because it means that the headers will only be emitted
after the body has been parsed.
---
 notmuch-show.c| 6 +++---
 test/T170-sexp.sh | 8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index fea99bff..4e918461 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -607,9 +607,6 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
sp->begin_map (sp);
format_message_sprinter (sp, node->envelope_file);
 
-   sp->map_key (sp, "headers");
-   format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
-
if (output_body) {
sp->map_key (sp, "body");
sp->begin_list (sp);
@@ -643,6 +640,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
sp->end (sp);
}
 
+   sp->map_key (sp, "headers");
+   format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
+
sp->end (sp);
return;
 }
diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
index c3dcf52a..a42004f8 100755
--- a/test/T170-sexp.sh
+++ b/test/T170-sexp.sh
@@ -5,12 +5,12 @@ test_description="--format=sexp output"
 test_begin_subtest "Show message: sexp"
 add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[bcc]=\"test_suite+...@notmuchmail.org\"" 
"[reply-to]=\"test_suite+repl...@notmuchmail.org\"" 
"[body]=\"sexp-show-message\""
 output=$(notmuch show --format=sexp "sexp-show-message")
-test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite \" 
:To \"Notmuch Test Suite \" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+\") :body ((:id 1 :content-type \"text/plain\" :content 
\"sexp-show-message\n\"))) ("
+test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
\"text/plain\" :content \"sexp-show-message\n\")) :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite \" 
:To \"Notmuch Test Suite \" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+\")) ("
 
 # This should be the same output as above.
 test_begin_subtest "Show message: sexp --body=true"
 output=$(notmuch show --format=sexp --body=true "sexp-show-message")
-test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite \" 
:To \"Notmuch Test Suite \" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+\") :body ((:id 1 :content-type \"text/plain\" :content 
\"sexp-show-message\n\"))) ("
+test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type 
\"text/plain\" :content \"sexp-show-message\n\")) :headers (:Subject 
\"sexp-show-subject\" :From \"Notmuch Test Suite \" 
:To \"Notmuch Test Suite \" :Bcc 
\"test_suite+...@notmuchmail.org\" :Reply-To 
\"test_suite+repl...@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 
+\")) ("
 
 test_begin_subtest "Show message: sexp --body=false"
 output=$(notmuch show --format=sexp --body=false "sexp-show-message")
@@ -24,7 +24,7 @@ test_expect_equal "$output" "((:thread \"0002\" 
:timestamp 946728000
 test_begin_subtest "Show message: sexp, utf-8"
 add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 
2000 12:00:00 -\"" "[body]=\"jsön-show-méssage\""
 output=$(notmuch show --format=sexp "jsön-show-méssage")
-test_expect_equal "$output" ":id \"${gen_msg_id}\" :match t :excluded nil 
:filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative 
\"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject 
\"sexp-show-utf8-body-sübjéct\" :From \"Notmuch Test Suite 
\" :To \"Notmuch Test Suite 
\" :Date \"Sat, 01 Jan 2000 12:00:00 +\") :body 
((:id 1 :content-type \"text/plain\"