Re: [PATCH 07/10] emacs: Use --use-schema for search
authorMark Walters <markwalters1009@gmail.com>
Sat, 8 Dec 2012 08:48:26 +0000 (08:48 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:45 +0000 (09:51 -0800)
1b/45a77cc0983238cf26532440280a990b0cb100 [new file with mode: 0644]

diff --git a/1b/45a77cc0983238cf26532440280a990b0cb100 b/1b/45a77cc0983238cf26532440280a990b0cb100
new file mode 100644 (file)
index 0000000..f8739c7
--- /dev/null
@@ -0,0 +1,198 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 9F619431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 00:48:26 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 OJpy3cTkUwP2 for <notmuch@notmuchmail.org>;\r
+       Sat,  8 Dec 2012 00:48:24 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 0BB5E431FAE\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 00:48:24 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1ThG58-00069c-5s; Sat, 08 Dec 2012 08:48:22 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1ThG57-0004FC-Os; Sat, 08 Dec 2012 08:48:22 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 07/10] emacs: Use --use-schema for search\r
+In-Reply-To: <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
+References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+       <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sat, 08 Dec 2012 08:48:26 +0000\r
+Message-ID: <87ehj1gc9x.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 855dd0488c8187b0d0b2eda6089e4b62 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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, 08 Dec 2012 08:48:26 -0000\r
+\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
+Incidentally why does show always pop-up an error but search only for\r
+version-mismatches?\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
+> 1.7.10.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r