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