Re: [PATCH v5.2 3/7] reply: Add a JSON reply format.
authorAustin Clements <amdragon@MIT.EDU>
Sat, 18 Feb 2012 03:23:52 +0000 (22:23 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:39 +0000 (09:44 -0800)
21/6838140433901ffc5b375a6fed8678ceeea6bb [new file with mode: 0644]

diff --git a/21/6838140433901ffc5b375a6fed8678ceeea6bb b/21/6838140433901ffc5b375a6fed8678ceeea6bb
new file mode 100644 (file)
index 0000000..af30950
--- /dev/null
@@ -0,0 +1,152 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2BE95431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 17 Feb 2012 19:25:43 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id R4oOjfJOOD7l for <notmuch@notmuchmail.org>;\r
+       Fri, 17 Feb 2012 19:25:42 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
+       [18.7.68.37])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7F3CF431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 17 Feb 2012 19:25:42 -0800 (PST)\r
+X-AuditID: 12074425-b7f4a6d0000008e0-c5-4f3f1a34da45\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 9A.11.02272.43A1F3F4; Fri, 17 Feb 2012 22:25:40 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q1I3PdCr014641; \r
+       Fri, 17 Feb 2012 22:25:39 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q1I3PbY0017290\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 17 Feb 2012 22:25:38 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Ryats-0004Bi-3T; Fri, 17 Feb 2012 22:23:52 -0500\r
+Date: Fri, 17 Feb 2012 22:23:52 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+Subject: Re: [PATCH v5.2 3/7] reply: Add a JSON reply format.\r
+Message-ID: <20120218032352.GI5991@mit.edu>\r
+References: <1329361957-28493-1-git-send-email-awg+notmuch@xvx.ca>\r
+       <1329361957-28493-4-git-send-email-awg+notmuch@xvx.ca>\r
+       <20120217170457.GE5991@mit.edu>\r
+       <CAMoJFUt_um9wTVaGEBm+9VmRcb1QZoOnbVCOrBQ7bfhjVQM9zg@mail.gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=iso-8859-1\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To:\r
+ <CAMoJFUt_um9wTVaGEBm+9VmRcb1QZoOnbVCOrBQ7bfhjVQM9zg@mail.gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprDKsWRmVeSWpSXmKPExsUixG6nomsiZe9v8PIXp8WRPbPYLa7fnMns\r
+       wOTxbNUtZo+mH4tZA5iiuGxSUnMyy1KL9O0SuDI+zW5hLOiVqZh79Th7A+MBsS5GTg4JAROJ\r
+       Q4fXM0PYYhIX7q1n62Lk4hAS2McosfPFJXYIZwOjxOUJ/6AyJ5kktj2fwQLhLGGUuH2xB8jh\r
+       4GARUJW4eNcRZBSbgIbEtv3LGUFsEQEtiR/rv7KC2MwC0hLffjczgdjCArYSzz5dAlvNK6At\r
+       cerqDGaImU8YJU6cWMsCkRCUODnzCQtEs47Ezq132EB2gQxa/o8DIiwv0bx1NtgcToFAib2H\r
+       1oLNFxVQkZhychvbBEbhWUgmzUIyaRbCpFlIJi1gZFnFKJuSW6Wbm5iZU5yarFucnJiXl1qk\r
+       a6GXm1mil5pSuokRHAkuqjsYJxxSOsQowMGoxMP7qtPOX4g1say4MvcQoyQHk5Io7xkxe38h\r
+       vqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrxed4DKeVMSK6tSi/JhUtIcLErivJpa7/yEBNITS1Kz\r
+       U1MLUotgsjIcHEoSvNmSQEMFi1LTUyvSMnNKENJMHJwgw3mAhneB1PAWFyTmFmemQ+RPMSpK\r
+       ifPmgyQEQBIZpXlwvbBE9YpRHOgVYd5WkCoeYJKD634FNJgJaDCvEMjVxSWJCCmpBsZdR6cI\r
+       m81cGXXG9TxXQ8+jRZZTdFvaGvWknuw5+0Bjn4im1P4dx+/Gpbi1e+yX3y/84rHGuTLhuMJ5\r
+       bGvLlZ88ubvoTut+2cZrO3I3XnW7YDvF/9i7KlsmU/GQwu+OMbsn9a9qaWXh3Wx4RrLKIGn6\r
+       Bu6wy2Iq5bpr599c/aJsLqON0EWN35JKLMUZiYZazEXFiQA0LyOPLwMAAA==\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 18 Feb 2012 03:25:43 -0000\r
+\r
+Quoth Adam Wolfe Gordon on Feb 17 at  7:06 pm:\r
+> On Fri, Feb 17, 2012 at 10:04, Austin Clements <amdragon@mit.edu> wrote:\r
+> > The first two patches LGTM.  A few nits in this one.\r
+> \r
+> Thanks for the review. A couple of points to discuss below; everything\r
+> else I'll change for the next version.\r
+> \r
+> >> +void\r
+> >> +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first);\r
+> >> +\r
+> >\r
+> > This is the wrong place for this declaration, since it is not part of\r
+> > the MIME node abstraction.  It should go somewhere above the /*\r
+> > notmuch-config.c */ comment.  Above that, it's a bit of a jumble.  I'd\r
+> > probably put it right after notmuch_show_command.\r
+> \r
+> Agreed. I initially had it earlier in the file (with the other\r
+> show-related functions), but moved it down since it requires the\r
+> mime_node_t declaration. There are a couple of options: put in a\r
+> pre-declaration of mime_node_t early in the file, or move the\r
+> mime_node stuff to a separate header file and include it in\r
+> notmuch-client.h. I lean toward the latter, since notmuch-client.h is\r
+> getting very big as it is. Thoughts?\r
+\r
+struct mime_node is already declared at the top of notmuch-client.h.\r
+That should probably just be replaced with\r
+ typedef struct mime_node mime_node_t;\r
+(and notmuch_show_format.part can be updated to take a mime_node_t *).\r
+Alternatively, you could change your declaration to take a struct\r
+mime_node, but it's nicer if the declaration and the definition match\r
+literally and not just logically.  Moving mime_node_t into its own\r
+header isn't a bad idea on its own (in fact, I specifically wrote it\r
+so it could live in util/ if we wanted), but seems like overkill for\r
+this.\r
+\r
+> >> +    if (notmuch_query_count_messages (query) != 1) {\r
+> >> +     fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+> >> +     return 1;\r
+> >> +    }\r
+> >\r
+> > Technically count_messages does not have to be accurate, but since\r
+> > this is the same thing notmuch-show does, it's probably fine for now.\r
+> \r
+> Ah, I didn't realize this. I just followed the show example.\r
+\r
+I think it's fine as is.  Probably as a later, independent patch, we\r
+should update both places to just check the iterator after the call to\r
+notmuch_messages_get.  Or you could update it as an extra minipatch in\r
+your series if you want.\r
+\r
+> > Perhaps we should add proper handling of multi-message replies to\r
+> > devel/TODO?\r
+> \r
+> Probably a good idea, although it means defining what proper handling\r
+> of multi-message replies in the CLI means. Personally, I don't think\r
+> it makes much sense to reply to multiple messages. The only place that\r
+> functionality is actually used (AFAIK) is in notmuch-search.el, which,\r
+> with my patches, throws an error if you try to reply to a thread\r
+> containing multiple messages. In my mind, the correct behavior in that\r
+> specific case is to create a reply to the last message in the thread,\r
+> which is better handled in the emacs code than the CLI anyway.\r
+\r
+*Doing* it requires defining what it means, but devel/TODO is a fine\r
+place for arbitrarily fantastical and under-specified desires.  That\r
+said, I don't think defining it is that hard.  We could just do\r
+whatever mutt does.  The body of a multi-message reply in mutt is the\r
+concatenation of the bodies that would be generated for individual\r
+replies and I suspect the headers are the gathered up to/cc addresses,\r
+an in-reply-to that lists all of the replied to message IDs, and a\r
+subject and references header derived from the first message replied\r
+to.\r