Re: [PATCH 07/10] emacs: Use --use-schema for search
authorAustin Clements <amdragon@MIT.EDU>
Thu, 13 Dec 2012 01:43:41 +0000 (20:43 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:05 +0000 (09:52 -0800)
fd/dce081ba07f58f3225a2174558daf483b6eb40 [new file with mode: 0644]

diff --git a/fd/dce081ba07f58f3225a2174558daf483b6eb40 b/fd/dce081ba07f58f3225a2174558daf483b6eb40
new file mode 100644 (file)
index 0000000..60b2499
--- /dev/null
@@ -0,0 +1,218 @@
+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 1AB3C431FBC\r
+       for <notmuch@notmuchmail.org>; Wed, 12 Dec 2012 17:43:48 -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 4Nu0CA6EZrxn for <notmuch@notmuchmail.org>;\r
+       Wed, 12 Dec 2012 17:43:47 -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 26B4E431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 12 Dec 2012 17:43:47 -0800 (PST)\r
+X-AuditID: 12074425-b7f606d0000008ea-a2-50c932d00b46\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 08.90.02282.0D239C05; Wed, 12 Dec 2012 20:43:44 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qBD1hh9a001222; \r
+       Wed, 12 Dec 2012 20:43:44 -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 qBD1hfCP022937\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Wed, 12 Dec 2012 20:43:42 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Tixpt-0000HJ-7j; Wed, 12 Dec 2012 20:43:41 -0500\r
+Date: Wed, 12 Dec 2012 20:43:41 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 07/10] emacs: Use --use-schema for search\r
+Message-ID: <20121213014341.GC6187@mit.edu>\r
+References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+       <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
+       <87ehj1gc9x.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87ehj1gc9x.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1r1gdDLA4N8HfovVc3ksrt+cyezA\r
+       5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZSx7/pSx4KpOxbuPfYwNjPcVuxg5OSQETCRW\r
+       Pd7CDGGLSVy4t56ti5GLQ0hgH6PEst33oZwNjBLX/t9mhXAuMklM/PWYEcJZwihxeNNNli5G\r
+       Dg4WAVWJCUtqQUaxCWhIbNu/nBHEFhHQkbh9aAE7iM0sIC3x7XczE4gtLGArsWjlLVYQm1dA\r
+       W2Jq30aobZMZJd63PoNKCEqcnPmEBaJZS+LGv5dMILtABi3/xwES5gTa9enXT7CZogIqElNO\r
+       bmObwCg0C0n3LCTdsxC6FzAyr2KUTcmt0s1NzMwpTk3WLU5OzMtLLdK10MvNLNFLTSndxAgK\r
+       a3YX1R2MEw4pHWIU4GBU4uHVeHM8QIg1say4MvcQoyQHk5Ior4rhyQAhvqT8lMqMxOKM+KLS\r
+       nNTiQ4wSHMxKIrxlukA53pTEyqrUonyYlDQHi5I4742Um/5CAumJJanZqakFqUUwWRkODiUJ\r
+       3tsgQwWLUtNTK9Iyc0oQ0kwcnCDDeYCGrwOp4S0uSMwtzkyHyJ9iVJQS590PkhAASWSU5sH1\r
+       wtLOK0ZxoFeEeVeDVPEAUxZc9yugwUxAg+MuHQcZXJKIkJJqYLzMqjj1s5SGTWWe9530kgVi\r
+       uYq1B5LsHiumeXcq/Xi27qWmzoEFE3V2XFG12Ha1TCBO869P6/Z+/9D8n/PErZddKLXZqrng\r
+       tQp/0Mam7Yc0Gx70z2o/4N2Z/my9aFO28t+ofs7Z2go5glKBG/5Vy998sa1KfHqhzfqdLKZq\r
+       S6YI8+2vj0lfrMRSnJFoqMVcVJwIAEZWRaUWAwAA\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: Thu, 13 Dec 2012 01:43:48 -0000\r
+\r
+Quoth Mark Walters on Dec 08 at  8:48 am:\r
+> On Sun, 02 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> > We detect the special exit statuses and use these to produce specific\r
+> > diagnostic messages.\r
+> > ---\r
+> >  emacs/notmuch-lib.el |   32 ++++++++++++++++++++++++++++++++\r
+> >  emacs/notmuch.el     |   17 +++++++++++++----\r
+> >  2 files changed, 45 insertions(+), 4 deletions(-)\r
+> >\r
+> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+> > index 9402456..49b0da6 100644\r
+> > --- a/emacs/notmuch-lib.el\r
+> > +++ b/emacs/notmuch-lib.el\r
+> > @@ -325,6 +325,38 @@ string), a property list of face attributes, or a list of these."\r
+> >    (put-text-property pos next 'face (cons face cur))\r
+> >    (setq pos next)))))\r
+> >  \r
+> > +(defun notmuch-pop-up-error (msg)\r
+> > +  "Pop up an error buffer displaying MSG."\r
+> > +\r
+> > +  (let ((buf (get-buffer-create "*Notmuch errors*")))\r
+> > +    (with-current-buffer buf\r
+> > +      (view-mode)\r
+> > +      (let ((inhibit-read-only t))\r
+> > +  (erase-buffer)\r
+> > +  (insert msg)\r
+> > +  (unless (bolp)\r
+> > +    (insert "\n"))\r
+> > +  (goto-char (point-min))))\r
+> > +    (pop-to-buffer buf)))\r
+> \r
+> I am not sure about the erase-buffer in the above: do we definitely want\r
+> to remove all previous error information? For version mismatch possibly\r
+> we do but in patch 9 it is done for all show command-line error returns.\r
+\r
+Why wouldn't we want to use a cleared buffer in all cases?\r
+notmuch-pop-up-error is only ever used when a command terminates, so\r
+there's no danger of us clearing errors that the user hasn't seen yet.\r
+\r
+> Incidentally why does show always pop-up an error but search only for\r
+> version-mismatches?\r
+\r
+Historical reasons, I suppose.  I was maintaining the status quo for\r
+search (which already had *some* error handling), but there was no\r
+error-handling status quo for show.  Probably search should be more\r
+vocal when the command fails.\r
+\r
+> Otherwise this looks good to me (but I am not that familiar with lisp\r
+> error handling)\r
+> \r
+> Best wishes\r
+> \r
+> Mark\r
+> \r
+> \r
+> \r
+> \r
+> \r
+> \r
+> > +(defun notmuch-version-mismatch-error (exit-status)\r
+> > +  "Signal a schema version mismatch error.\r
+> > +\r
+> > +EXIT-STATUS must be the exit status of the notmuch CLI command,\r
+> > +and must have the value 20 or 21.  This function will pop up an\r
+> > +error buffer with a descriptive message and signal an error."\r
+> > +  (cond ((= exit-status 20)\r
+> > +   (notmuch-pop-up-error "Error: Version mismatch.\r
+> > +Emacs requested an older output format than supported by the notmuch CLI.\r
+> > +You may need to restart Emacs or upgrade your notmuch Emacs package."))\r
+> > +  ((= exit-status 21)\r
+> > +   (notmuch-pop-up-error "Error: Version mismatch.\r
+> > +Emacs requested a newer output format than supported by the notmuch CLI.\r
+> > +You may need to restart Emacs or upgrade your notmuch package."))\r
+> > +  (t\r
+> > +   (error "Bad exit status %d" exit-status)))\r
+> > +  (error "notmuch CLI version mismatch"))\r
+> > +\r
+> >  ;; Compatibility functions for versions of emacs before emacs 23.\r
+> >  ;;\r
+> >  ;; Both functions here were copied from emacs 23 with the following copyright:\r
+> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> > index f9454d8..e1f28ca 100644\r
+> > --- a/emacs/notmuch.el\r
+> > +++ b/emacs/notmuch.el\r
+> > @@ -644,6 +644,7 @@ of the result."\r
+> >    (exit-status (process-exit-status proc))\r
+> >    (never-found-target-thread nil))\r
+> >      (when (memq status '(exit signal))\r
+> > +      (catch 'return\r
+> >    (kill-buffer (process-get proc 'parse-buf))\r
+> >    (if (buffer-live-p buffer)\r
+> >        (with-current-buffer buffer\r
+> > @@ -655,8 +656,16 @@ of the result."\r
+> >                  (insert "Incomplete search results (search process was killed).\n"))\r
+> >              (when (eq status 'exit)\r
+> >                (insert "End of search results.")\r
+> > -              (unless (= exit-status 0)\r
+> > -                (insert (format " (process returned %d)" exit-status)))\r
+> > +              (cond ((or (= exit-status 20) (= exit-status 21))\r
+> > +                     (kill-buffer)\r
+> > +                     (condition-case err\r
+> > +                         (notmuch-version-mismatch-error exit-status)\r
+> > +                       ;; Strange things happen when you signal\r
+> > +                       ;; an error from a sentinel.\r
+> > +                       (error (throw 'return nil))))\r
+> > +                    ((/= exit-status 0)\r
+> > +                     (insert (format " (process returned %d)"\r
+> > +                                     exit-status))))\r
+> >                (insert "\n")\r
+> >                (if (and atbob\r
+> >                         (not (string= notmuch-search-target-thread "found")))\r
+> > @@ -664,7 +673,7 @@ of the result."\r
+> >          (when (and never-found-target-thread\r
+> >                   notmuch-search-target-line)\r
+> >              (goto-char (point-min))\r
+> > -            (forward-line (1- notmuch-search-target-line))))))))\r
+> > +            (forward-line (1- notmuch-search-target-line)))))))))\r
+> >  \r
+> >  (defcustom notmuch-search-line-faces '(("unread" :weight bold)\r
+> >                                   ("flagged" :foreground "blue"))\r
+> > @@ -938,7 +947,7 @@ Other optional parameters are used as follows:\r
+> >    (let ((proc (start-process\r
+> >                 "notmuch-search" buffer\r
+> >                 notmuch-command "search"\r
+> > -               "--format=json"\r
+> > +               "--format=json" "--use-schema=1"\r
+> >                 (if oldest-first\r
+> >                     "--sort=oldest-first"\r
+> >                   "--sort=newest-first")\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+-- \r
+Austin Clements                                      MIT/'06/PhD/CSAIL\r
+amdragon@mit.edu                           http://web.mit.edu/amdragon\r
+       Somewhere in the dream we call reality you will find me,\r
+              searching for the reality we call dreams.\r