From: Mark Walters Date: Sat, 15 Dec 2012 09:33:42 +0000 (+0000) Subject: Re: [PATCH 6/7] emacs: Use unified error handling in search X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=cded1e87f98991df504199d359d650e713d18926;p=notmuch-archives.git Re: [PATCH 6/7] emacs: Use unified error handling in search --- diff --git a/47/e8167e4ea458ea46dcf741a468a252cabac89d b/47/e8167e4ea458ea46dcf741a468a252cabac89d new file mode 100644 index 000000000..75250288a --- /dev/null +++ b/47/e8167e4ea458ea46dcf741a468a252cabac89d @@ -0,0 +1,167 @@ +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 80D9C431FC0 + for ; Sat, 15 Dec 2012 01:33:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 HWGyivWwFFVF for ; + Sat, 15 Dec 2012 01:33:42 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B42B9431FBF + for ; Sat, 15 Dec 2012 01:33:42 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Tjo7p-0007I9-4L; Sat, 15 Dec 2012 09:33:41 +0000 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1Tjo7o-0006bT-RC; Sat, 15 Dec 2012 09:33:41 +0000 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 6/7] emacs: Use unified error handling in search +In-Reply-To: <1355548513-10085-7-git-send-email-amdragon@mit.edu> +References: <1355548513-10085-1-git-send-email-amdragon@mit.edu> + <1355548513-10085-7-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+155~g7edfdc3 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Sat, 15 Dec 2012 09:33:42 +0000 +Message-ID: <8738z7hd6x.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: db77e9b5c352b29a515faba4176923d6 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Sat, 15 Dec 2012 09:33:43 -0000 + + +On Sat, 15 Dec 2012, Austin Clements wrote: +> This slightly changes the output of an existing test since we now +> report non-zero exits with a pop-up buffer instead of at the end of +> the search results. +> --- +> emacs/notmuch-lib.el | 13 +++++++++++++ +> emacs/notmuch.el | 13 ++++++++----- +> test/emacs-large-search-buffer | 2 +- +> 3 files changed, 22 insertions(+), 6 deletions(-) +> +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index 9222de8..cf61635 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -332,6 +332,19 @@ the user dismisses it." +> (goto-char (point-min)))) +> (pop-to-buffer buf))) +> +> +(defun notmuch-check-async-exit-status (proc msg) +> + "If PROC exited abnormally, pop up an error buffer and signal an error. +> + +> +This is a wrapper around `notmuch-check-exit-status' for +> +asynchronous process sentinels. PROC and MSG must be the +> +arguments passed to the sentinel." +> + (let ((exit-status +> + (case (process-status proc) +> + ((exit) (process-exit-status proc)) +> + ((signal) msg)))) +> + (when exit-status +> + (notmuch-check-exit-status exit-status (process-command proc))))) +> + +> (defun notmuch-check-exit-status (exit-status command &optional output err-file) +> "If EXIT-STATUS is non-zero, pop up an error buffer and signal an error. +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index e25b54e..c20de13 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -637,6 +637,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 +> @@ -647,17 +648,19 @@ of the result." +> (if (eq status 'signal) +> (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))) +> - (insert "\n") +> + (insert "End of search results.\n") +> + (condition-case err +> + (notmuch-check-async-exit-status proc msg) +> + ;; Suppress the error signal since strange +> + ;; things happen if a sentinel signals. +> + (error (throw 'return nil))) + +A total triviality (mostly just to check that I am understanding these +parts): is the "err" after the condition-case used/needed? + +Best wishes + +Mark +> (if (and atbob +> (not (string= notmuch-search-target-thread "found"))) +> (set 'never-found-target-thread t))))) +> (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")) +> diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer +> index 678328d..9dcbef5 100755 +> --- a/test/emacs-large-search-buffer +> +++ b/test/emacs-large-search-buffer +> @@ -36,7 +36,7 @@ test_emacs '(notmuch-search "--this-option-does-not-exist") +> cat <EXPECTED +> Error: Unexpected output from notmuch search: +> Unrecognized option: --this-option-does-not-exist +> -End of search results. (process returned 1) +> +End of search results. +> EOF +> test_expect_equal_file OUTPUT EXPECTED +> +> -- +> 1.7.10.4