From db34131778043ad7da4e5903d5030cccc0c3c7f3 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Sun, 12 Jan 2014 16:00:00 +1100 Subject: [PATCH] [PATCH] show: add In-reply-to, References fields to structured formats --- ed/e3ca6947451493fac017a49f8582374ecbbc83 | 183 ++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 ed/e3ca6947451493fac017a49f8582374ecbbc83 diff --git a/ed/e3ca6947451493fac017a49f8582374ecbbc83 b/ed/e3ca6947451493fac017a49f8582374ecbbc83 new file mode 100644 index 000000000..557b3e34b --- /dev/null +++ b/ed/e3ca6947451493fac017a49f8582374ecbbc83 @@ -0,0 +1,183 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1308C431FD0 + for ; Sat, 11 Jan 2014 21:00:24 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id vY3wYX7PR+RK for ; + Sat, 11 Jan 2014 21:00:16 -0800 (PST) +Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com + [209.85.220.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id F3A76431FC3 + for ; Sat, 11 Jan 2014 21:00:15 -0800 (PST) +Received: by mail-pa0-f52.google.com with SMTP id kx10so2498821pab.25 + for ; Sat, 11 Jan 2014 21:00:14 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id; + bh=lScT2gNr4j5m5tnAQT9fzWjvIbwWVU4+DR0YvantN6k=; + b=0HrQSqWII1+4WKIAs0vDfA+oeMa2iSXVDqqkKivI+SEESuhDKRK2q5P/w44UDa4XbK + Q7zcOVSeZbxqVDBICiBQUqCgzjlMtpYQgtvZNu6GVGEepLL1KMS4RpqN7MT7lC2QEI8U + TiaqK9pAEgSOBwnBmUJ6gau8E1wuAUoU7j1ogSUunGIF4g0vQ9kNxYOPdqpuVyX/ldFw + yugUIJ26cQmrlc+/ipGjYm89quYMue9VFoO7Pv/83WHex4j5oaYUKYM1R+f4KETCn+jn + MbHGE1CsWWOxf2xwD31zv+p3cQyWs13Ksrh9HTZ+xST+5PmCaB+M2xB/x2zg1ZRe5Igi + Pvdw== +X-Received: by 10.68.234.67 with SMTP id uc3mr21589381pbc.27.1389502814070; + Sat, 11 Jan 2014 21:00:14 -0800 (PST) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) + by mx.google.com with ESMTPSA id sx8sm36257204pab.5.2014.01.11.21.00.11 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 11 Jan 2014 21:00:12 -0800 (PST) +From: Peter Wang +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 +Message-Id: <1389502800-9237-1-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.8.4 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 12 Jan 2014 05:00:24 -0000 + +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 ", + "To": "Notmuch Test Suite ", ++ "In-reply-to": "mumble", ++ "References": "", + "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 ", + "To": "Notmuch Test Suite ", ++ "In-reply-to": "", ++ "References": "", + "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 ", + "To": "Notmuch Test Suite ", ++ "In-reply-to": "", + "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 ", + "To": "Notmuch Test Suite ", ++ "In-reply-to": "", ++ "References": " ", + "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 + -- 2.26.2