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