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 E4DBD431FC0 for ; Sat, 15 Dec 2012 12:04:34 -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 54otia3fd5XB for ; Sat, 15 Dec 2012 12:04:34 -0800 (PST) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id CF3AE431FBC for ; Sat, 15 Dec 2012 12:04:33 -0800 (PST) X-AuditID: 1209190e-b7f516d0000008e4-e5-50ccd7d1e208 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 9E.06.02276.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-1.mit.edu (8.13.8/8.9.2) with ESMTP id qBFK4W5Q014181; 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 qBFK4SQZ025682 (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-0007sT-Jq; Sat, 15 Dec 2012 15:04:28 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 2/7] emacs: Use unified error handling in notmuch-call-notmuch-process Date: Sat, 15 Dec 2012 15:04:15 -0500 Message-Id: <1355601860-30121-3-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355601860-30121-1-git-send-email-amdragon@mit.edu> References: <1355601860-30121-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrHvx+pkAg1UfpCxWz+WxuH5zJrPF m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBlrLz3k6ngAE/Fod55bA2M c7i6GDk5JARMJP4cOcMOYYtJXLi3nq2LkYtDSGAfo8SOs53MIAkhgQ2MEk/nGkEkHjFJrOr4 yAjhzGWU6L0yHayKTUBDYtv+5YwgtoiAtMTOu7NZQWxmgTiJLVP+g8WFBSIlDm+7CWazCKhK LNyxmA3E5hVwkFi48hnUGYoS3c8mgMU5BRwlJk7exQRxhYPE7QVzmCYw8i9gZFjFKJuSW6Wb m5iZU5yarFucnJiXl1qka6yXm1mil5pSuokRHFySfDsYvx5UOsQowMGoxMO7I+J0gBBrYllx Ze4hRkkOJiVR3ozLZwKE+JLyUyozEosz4otKc1KLDzFKcDArifAmzQfK8aYkVlalFuXDpKQ5 WJTEea+k3PQXEkhPLEnNTk0tSC2CycpwcChJ8AoBo0hIsCg1PbUiLTOnBCHNxMEJMpwHaDgH SA1vcUFibnFmOkT+FKOilDivHUhCACSRUZoH1wuL/leM4kCvCPN+uAZUxQNMHHDdr4AGMwEN Xm4DNrgkESEl1cAYcHzTS8dfa6wNHq/5x/Lg4gP+ta8sAmdbGtR9Z+T8mu238n2C4IbuQ2tn ffRPudfRanNpvaKH8hLWov/B27XUw+9cjfIqT+O5eO3Vk17jWB++3KdWr3y/vTzR7C6lJJMX vP5odEbC3Sn+VpsaLGf8PvDdYod7qka2qoSVlGtWG++ps1eEvu9UYinOSDTUYi4qTgQA24gY 4dkCAAA= 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:35 -0000 This makes notmuch-call-notmuch-process use the unified CLI error handling, which basically refines the error handling this function already did. --- emacs/notmuch.el | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f9454d8..9da8df4 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -536,19 +536,13 @@ 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*\"." - (let ((error-buffer (get-buffer-create "*Notmuch errors*"))) - (with-current-buffer error-buffer - (erase-buffer)) - (if (eq (apply 'call-process notmuch-command nil error-buffer nil args) 0) - (point) - (progn - (with-current-buffer error-buffer - (let ((beg (point-min)) - (end (- (point-max) 1))) - (error (buffer-substring beg end)) - )))))) +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) + (buffer-string))))) (defun notmuch-search-set-tags (tags &optional pos) (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags))) -- 1.7.10.4