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 0EF1E431FC0 for ; Sat, 8 Dec 2012 16:47:44 -0800 (PST) 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 9ft3CFF5-6D0 for ; Sat, 8 Dec 2012 16:47:43 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 72A63431FAE for ; Sat, 8 Dec 2012 16:47:43 -0800 (PST) X-AuditID: 1209190c-b7f886d000000936-a2-50c3dfae5061 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id E3.95.02358.EAFD3C05; Sat, 8 Dec 2012 19:47:42 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qB90lf4G017333; Sat, 8 Dec 2012 19:47:42 -0500 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 qB90lecM014120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 8 Dec 2012 19:47:41 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1ThV3T-0005cB-Qx; Sat, 08 Dec 2012 19:47:39 -0500 Date: Sat, 8 Dec 2012 19:47:39 -0500 From: Austin Clements To: Mark Walters Subject: Re: [PATCH] emacs: query: make sync queries use sexp Message-ID: <20121209004739.GH4422@mit.edu> References: <1354975891-24663-1-git-send-email-markwalters1009@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1354975891-24663-1-git-send-email-markwalters1009@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1113/3CAwckrmhar5/JYXL85k9mB yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgymh7sICt4LtoxcU/K1kaGLcLdjFyckgImEis u7SPFcIWk7hwbz1bFyMXh5DAPkaJR4++skM46xklfr++wwrhXGCSOLz+MVTZEkaJDStes4P0 swioSCzePxtsFpuAhsS2/csZQWwRAR2J24cWgNUwC0hLfPvdzARiCwvYSqx7d4oNxOYV0Jb4 t3YZWFxIwFOif+scZoi4oMTJmU9YIHq1JG78ewlUwwE2Z/k/DpAwp4CXxNsZx8BaRYFOmHJy G9sERqFZSLpnIemehdC9gJF5FaNsSm6Vbm5iZk5xarJucXJiXl5qka6hXm5miV5qSukmRlBY c0ry7GB8c1DpEKMAB6MSD2/H7cMBQqyJZcWVuYcYJTmYlER594OE+JLyUyozEosz4otKc1KL DzFKcDArifC+LAfK8aYkVlalFuXDpKQ5WJTEeS+n3PQXEkhPLEnNTk0tSC2CycpwcChJ8F67 B9QoWJSanlqRlplTgpBm4uAEGc4DNPwMSA1vcUFibnFmOkT+FKOilDjvXpCEAEgiozQPrheW dl4xigO9Isy7EKSKB5iy4LpfAQ1mAhp8UhBscEkiQkqqgVE8e43cbXYW9es5zXM+h1sonY+u Nl2xXujZ0XvHj7C/Mfl6Xys8k6e2p28Td4a2Wq197Z/P6ZUc6Uf4kl8uvRQy7aCfz/TrEQ21 kSc5tN794ZRfJJaqvTCEkWXv/02ugkqWmQkzMyf/vLjs4k+h2fN1L+28phja/T/Ml/GSUMv/ iA2/3x0ufKTEUpyRaKjFXFScCAAtTNGaFgMAAA== 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: Sun, 09 Dec 2012 00:47:44 -0000 sexp-at-point is a pretty roundabout way to parse this that I think will basically parse the S-expression three times (in end-of-sexp, in beginning-of-sexp, and then for real in read-from-whole-string). How about (prog1 (read (current-buffer)) (skip-chars-forward " \t\n\f") (unless (eobp) (error "Trailing garbage after notmuch output"))) ? Technically, just the (read (current-buffer)) part would be equivalent to the current (json-read) call (which will ignore any trailing garbage). There's also another synchronous JSON query in notmuch-mua.el that should be fixed. I wouldn't worry too much about the error handling. I don't think this can deal worse with errors than the current JSON code does. My schema versioning series has a patch [1] that should help improve error handling. It's for JSON right now, but will be trivial to port to S-expressions. [1] id:1354416002-3557-9-git-send-email-amdragon@mit.edu Quoth Mark Walters on Dec 08 at 2:11 pm: > This changes the queries used by notmuch-show from json to sexp (patch > based on a comment by Tomi on irc as to the trivial change needed). > > The async query parsed used by search is not as easy to convert. > --- > > It's probably worth making this change: sexps are significantly faster > but I doubt anyone would notice in show (since the query is small and > the wash processing etc relatively large). > > At the moment this doesn't do any error fixing. The json version did > not either but the sexp parser and the json parser might behave > differently on malformed input. > > Best wishes > > Mark > > > emacs/notmuch-query.el | 7 ++----- > 1 files changed, 2 insertions(+), 5 deletions(-) > > diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el > index d66baea..0ee6cca 100644 > --- a/emacs/notmuch-query.el > +++ b/emacs/notmuch-query.el > @@ -29,10 +29,7 @@ A thread is a forest or list of trees. A tree is a two element > list where the first element is a message, and the second element > is a possibly empty forest of replies. > " > - (let ((args '("show" "--format=json")) > - (json-object-type 'plist) > - (json-array-type 'list) > - (json-false 'nil)) > + (let ((args '("show" "--format=sexp"))) > (if notmuch-show-process-crypto > (setq args (append args '("--decrypt")))) > (setq args (append args search-terms)) > @@ -40,7 +37,7 @@ is a possibly empty forest of replies. > (progn > (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args)) > (goto-char (point-min)) > - (json-read))))) > + (sexp-at-point))))) > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; Mapping functions across collections of messages.