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 14BAA431FC7 for ; Sat, 15 Dec 2012 12:04:36 -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 Zxfbhc3euh5q for ; Sat, 15 Dec 2012 12:04:35 -0800 (PST) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id B24A4431FC2 for ; Sat, 15 Dec 2012 12:04:34 -0800 (PST) X-AuditID: 1209190d-b7f266d00000092b-81-50ccd7d1c647 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id BD.DB.02347.1D7DCC05; Sat, 15 Dec 2012 15:04:33 -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 qBFK4WQG022933; Sat, 15 Dec 2012 15:04:32 -0500 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBFK4SYq025680 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 15 Dec 2012 15:04:31 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1TjxyG-0007sP-Gd; Sat, 15 Dec 2012 15:04:28 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 0/7] Improve Emacs CLI error handling Date: Sat, 15 Dec 2012 15:04:13 -0500 Message-Id: <1355601860-30121-1-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixCmqrXvx+pkAg3ddMhar5/JYXL85k9ni zcp5rA7MHjtn3WX3OPx1IYvHs1W3mAOYo7hsUlJzMstSi/TtErgydvU8YyrYK16x7sQB5gbG XuEuRk4OCQETiYuvOhkhbDGJC/fWs3UxcnEICexjlGj4MIcdwtnAKHF6+XEmCOcRk8TUzxeZ IZy5jBL3+lvZQfrZBDQktu1fDjZLREBaYufd2awgNrOAocTlrx0sILawgIXE2YVfmUFsFgFV iVeTn4PFeQUcJLbt2M0McYeiRPezCWwTGHkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXS y80s0UtNKd3ECA4XSd4djO8OKh1iFOBgVOLh3RFxOkCINbGsuDL3EKMkB5OSKG/G5TMBQnxJ +SmVGYnFGfFFpTmpxYcYJTiYlUR4k+YD5XhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqem FqQWwWRlODiUJHinXgNqFCxKTU+tSMvMKUFIM3FwggznARreDVLDW1yQmFucmQ6RP8WoKCXO uxAkIQCSyCjNg+uFxfMrRnGgV4R5q0CqeICpAK77FdBgJqDBy23ABpckIqSkGhg1WcInhGdK x5X9Nl6dYSp5OGCuy0Gl/exXXqadsfvftfzM6bP+qkx7ozjePZzGoZCr9T66Q2DCpvI5c2/9 WRFaqbe+La7+hJIuqxXbTYdjHD926S1udGUovTRdfQ9PwdH6rx85Tu50+ODQ7eBbX7Pa+ulr me983B7r25h2zbOLWSaa5epvL6/EUpyRaKjFXFScCACrPKL1wgIAAA== Cc: tomi.ollila@iki.fi 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 20:04:36 -0000 This obsoletes id:1355548513-10085-1-git-send-email-amdragon@mit.edu and fixes the things Mark and Tomi commented on. The interdiff is below. diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index cf61635..8f84087 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -326,10 +326,12 @@ the user dismisses it." (with-current-buffer buf (view-mode-enter nil #'kill-buffer) (let ((inhibit-read-only t)) + (goto-char (point-max)) + (unless (bobp) + (insert "\n")) (insert msg) (unless (bolp) - (insert "\n")) - (goto-char (point-min)))) + (insert "\n")))) (pop-to-buffer buf))) (defun notmuch-check-async-exit-status (proc msg) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c20de13..b0fd387 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -536,8 +536,9 @@ If BARE is set then do not prefix with \"thread:\"" (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. -Output from the process will be presented to the user as an error -and will also appear in a buffer named \"*Notmuch errors*\"." +If notmuch exits with a non-zero status, output from the process +will appear in a buffer named \"*Notmuch errors*\" and an error +will be signaled." (with-temp-buffer (let ((status (apply #'call-process notmuch-command nil t nil args))) (notmuch-check-exit-status status (cons notmuch-command args) @@ -649,7 +650,7 @@ of the result." (insert "Incomplete search results (search process was killed).\n")) (when (eq status 'exit) (insert "End of search results.\n") - (condition-case err + (condition-case nil (notmuch-check-async-exit-status proc msg) ;; Suppress the error signal since strange ;; things happen if a sentinel signals. diff --git a/test/emacs b/test/emacs index 88b062c..5067d67 100755 --- a/test/emacs +++ b/test/emacs @@ -873,7 +873,7 @@ This is output Error: Unexpected output from notmuch search: This is an error End of search results. -Error invoking notmuch. /tmp/nmtest/tmp.emacs/notmuch_fail search --format=json --sort=newest-first tag:inbox exited with status 1." +Error invoking notmuch. $PWD/notmuch_fail search --format=json --sort=newest-first tag:inbox exited with status 1." test_done diff --git a/test/emacs-show b/test/emacs-show index c67c6a4..40fab61 100755 --- a/test/emacs-show +++ b/test/emacs-show @@ -178,7 +178,7 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) (with-current-buffer \"*Notmuch errors*\" (test-output \"ERROR\")))" test_expect_equal "$(cat OUTPUT ERROR)" "\ -Error invoking notmuch. /tmp/nmtest/tmp.emacs-show/notmuch_fail show --format=json --exclude=false ' * ' exited with status 1. +Error invoking notmuch. $PWD/notmuch_fail show --format=json --exclude=false ' * ' exited with status 1. Error: This is an error Output: