--- /dev/null
+Return-Path: <bremner@tethera.net>\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 1AAB2431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Mar 2013 05:05:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 8L8hs4WGjdIC for <notmuch@notmuchmail.org>;\r
+ Fri, 8 Mar 2013 05:05:06 -0800 (PST)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 891D1431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Mar 2013 05:05:06 -0800 (PST)\r
+Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+ ([156.34.82.78] helo=zancas.localnet)\r
+ by tesseract.cs.unb.ca with esmtpsa\r
+ (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1UDwyq-0000H6-QF; Fri, 08 Mar 2013 09:05:04 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1UDwyl-0000wb-3V; Fri, 08 Mar 2013 09:04:55 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: introduce notmuch-command-to-string,\r
+ replace use of shell-command-to-string\r
+Date: Fri, 8 Mar 2013 09:04:38 -0400\r
+Message-Id: <1362747878-3571-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.2.rc1\r
+In-Reply-To: <874nguxbvq.fsf@tu-dortmund.de>\r
+References: <874nguxbvq.fsf@tu-dortmund.de>\r
+X-Spam_bar: -\r
+Cc: David Bremner <bremner@debian.org>,\r
+ Simon Campese <notmuchmail_org@campese.de>\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: Fri, 08 Mar 2013 13:05:10 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+This has two benefits: unified error handling, and avoiding tramp's\r
+hooking into shell-command-string.\r
+\r
+This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de\r
+---\r
+\r
+Simon: can you check if this fixes your bug?\r
+\r
+ emacs/notmuch-lib.el | 22 ++++++++++++++++------\r
+ 1 file changed, 16 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 270e3dc..556b1a4 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
+ (select-window (posn-window (event-start last-input-event)))\r
+ (button-activate button)))\r
+ \r
++(defun notmuch-command-to-string (&rest args)\r
++ "Synchronously invoke \"notmuch\" with the given list of arguments.\r
++\r
++If notmuch exits with a non-zero status, output from the process\r
++will appear in a buffer named \"*Notmuch errors*\" and an error\r
++will be signaled.\r
++\r
++Otherwise the output will be returned"\r
++ (with-temp-buffer\r
++ (let* ((status (apply #'call-process notmuch-command nil t nil args))\r
++ (output (buffer-string)))\r
++ (notmuch-check-exit-status status (cons notmuch-command args) output)\r
++ output)))\r
++\r
+ (defun notmuch-version ()\r
+ "Return a string with the notmuch version number."\r
+ (let ((long-string\r
+ ;; Trim off the trailing newline.\r
+- (substring (shell-command-to-string\r
+- (concat notmuch-command " --version"))\r
+- 0 -1)))\r
++ (substring (notmuch-command-to-string "--version") 0 -1))\r
+ (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"\r
+ long-string)\r
+ (match-string 2 long-string)\r
+@@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
+ (defun notmuch-config-get (item)\r
+ "Return a value from the notmuch configuration."\r
+ ;; Trim off the trailing newline\r
+- (substring (shell-command-to-string\r
+- (concat notmuch-command " config get " item))\r
+- 0 -1))\r
++ (substring (notmuch-command-to-string "config" "get" item) 0 -1))\r
+ \r
+ (defun notmuch-database-path ()\r
+ "Return the database.path value from the notmuch configuration."\r
+-- \r
+1.8.2.rc1\r
+\r