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 90550431FAF for ; Thu, 12 Jul 2012 17:10:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 FaBU+HK2vsNG for ; Thu, 12 Jul 2012 17:10:40 -0700 (PDT) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id 03E8F431FAE for ; Thu, 12 Jul 2012 17:10:39 -0700 (PDT) X-AuditID: 12074424-b7f2a6d0000008bf-4b-4fff677fd5d0 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 72.57.02239.F776FFF4; Thu, 12 Jul 2012 20:10:39 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0AdxB006693; Thu, 12 Jul 2012 20:10:39 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6D0AcfK002299 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 12 Jul 2012 20:10:38 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1SpTSv-00057N-W3; Thu, 12 Jul 2012 20:10:38 -0400 Date: Thu, 12 Jul 2012 20:10:37 -0400 From: Austin Clements To: craven@gmx.net Subject: Re: [PATCH v4 3/3] Use the structured format printer for JSON in notmuch search. Message-ID: <20120713001037.GL7332@mit.edu> References: <87d34hsdx8.fsf@awakening.csail.mit.edu> <1342079004-5300-1-git-send-email-craven@gmx.net> <1342079004-5300-4-git-send-email-craven@gmx.net> <20120713000234.GK7332@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120713000234.GK7332@mit.edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplleLIzCtJLcpLzFFi42IRYrdT0a1P/+9vsH6FjMXehnZGi+s3ZzI7 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBm7vs1kLnjCW3HkeCdzA2MjdxcjJ4eEgInE 712fWCFsMYkL99azdTFycQgJ7GOUaL9zgBHC2cAo8fvHZyYI5ySTxKGr96CcJYwSR9etYAfp ZxFQlfj1fRsLiM0moCGxbf9yRhBbREBIYtKXV2BxZgFpiW+/m5lAbGGBaIkJ0y6D2bwC2hJ/ Gt8xw+1+NO8YK0RCUOLkzCdQzVoSN/69BGrgABu0/B8HSJhTQEfiaPsJsHJRARWJKSe3sU1g FJqFpHsWku5ZCN0LGJlXMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zrr5WaW6KWmlG5iBIe2i8oO xuZDSocYBTgYlXh4f8X+9xdiTSwrrsw9xCjJwaQkyjs/FSjEl5SfUpmRWJwRX1Sak1p8iFGC g1lJhHedPVCONyWxsiq1KB8mJc3BoiTOez3lpr+QQHpiSWp2ampBahFMVoaDQ0mC91waUKNg UWp6akVaZk4JQpqJgxNkOA/Q8L0gNbzFBYm5xZnpEPlTjIpS4rxtIAkBkERGaR5cLyz1vGIU B3pFGKKdB5i24LpfAQ1mAho86+c/kMEliQgpqQZG35z3/GsatiUdlbNtemB7k7k/4ym7f9tM i4k/JV50nSly3nGU9eeft96VMTuqfRsyrrfIbrNPf7zZMif9eMjaiBwuxtPFPCn2radsvvzd 5263J6vV7cXSGyl+novl3AsYdx98vfsHs9+UEO9Htn7xc9zWlM1o2Kxx/srSuYq102Lf7Sw5 GqCmxFKckWioxVxUnAgAmxy7gRgDAAA= Cc: notmuch@notmuchmail.org 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: Fri, 13 Jul 2012 00:10:40 -0000 Quoth myself on Jul 12 at 8:02 pm: > This is fantastic. It simplifies the code a lot, and I think it opens > up opportunities to simplify it even further. > > Detailed comments are below, but first one general comment. For the > text format, I wonder if most of the special case code would go away > with a stub sprinter that did nothing for most operations and for > string printed the string followed by a newline (or maybe the newline > would be printed by the "frame" method or whatever you end up calling > it). I believe this would unify all of the code in do_search_tags and > do_search_files between the two formats. For do_search_threads, > you'll still need some special-casing to format the summary line, but > I think it would unify all of the framing code. (If this does work > out, some of my comments below will be irrelevant.) Oh, wait, the text format adds prefixes... I think something along the lines of what I described above would still simplify things. I can think of two ways to do it. You could have a completely stub sprinter where everything is a no-op; that would at least save the predication of calls like format->begin_list (). Or, you could have an additional function for the text formatter that registers a prefix, and have the string method first print that prefix and then the argument string. This additional function doesn't have to be a method of sprinter; it could just be a regular function that stashes the prefix away somewhere (a global variable's probably fine; if you want to be fancy you store it in an sprinter_text extension of sprinter_t like the one JSON uses). For the JSON format, this would be a no-op, so you could call it regardless of what format you've selected.