1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 1AAB2431FAF
\r
6 for <notmuch@notmuchmail.org>; Fri, 8 Mar 2013 05:05:10 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 8L8hs4WGjdIC for <notmuch@notmuchmail.org>;
\r
16 Fri, 8 Mar 2013 05:05:06 -0800 (PST)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 891D1431FAE
\r
21 for <notmuch@notmuchmail.org>; Fri, 8 Mar 2013 05:05:06 -0800 (PST)
\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.82.78] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)
\r
26 (envelope-from <bremner@tethera.net>)
\r
27 id 1UDwyq-0000H6-QF; Fri, 08 Mar 2013 09:05:04 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1UDwyl-0000wb-3V; Fri, 08 Mar 2013 09:04:55 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH] emacs: introduce notmuch-command-to-string,
\r
34 replace use of shell-command-to-string
\r
35 Date: Fri, 8 Mar 2013 09:04:38 -0400
\r
36 Message-Id: <1362747878-3571-1-git-send-email-david@tethera.net>
\r
37 X-Mailer: git-send-email 1.8.2.rc1
\r
38 In-Reply-To: <874nguxbvq.fsf@tu-dortmund.de>
\r
39 References: <874nguxbvq.fsf@tu-dortmund.de>
\r
41 Cc: David Bremner <bremner@debian.org>,
\r
42 Simon Campese <notmuchmail_org@campese.de>
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Fri, 08 Mar 2013 13:05:10 -0000
\r
57 From: David Bremner <bremner@debian.org>
\r
59 This has two benefits: unified error handling, and avoiding tramp's
\r
60 hooking into shell-command-string.
\r
62 This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
\r
65 Simon: can you check if this fixes your bug?
\r
67 emacs/notmuch-lib.el | 22 ++++++++++++++++------
\r
68 1 file changed, 16 insertions(+), 6 deletions(-)
\r
70 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
71 index 270e3dc..556b1a4 100644
\r
72 --- a/emacs/notmuch-lib.el
\r
73 +++ b/emacs/notmuch-lib.el
\r
74 @@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and add an
\r
75 (select-window (posn-window (event-start last-input-event)))
\r
76 (button-activate button)))
\r
78 +(defun notmuch-command-to-string (&rest args)
\r
79 + "Synchronously invoke \"notmuch\" with the given list of arguments.
\r
81 +If notmuch exits with a non-zero status, output from the process
\r
82 +will appear in a buffer named \"*Notmuch errors*\" and an error
\r
85 +Otherwise the output will be returned"
\r
87 + (let* ((status (apply #'call-process notmuch-command nil t nil args))
\r
88 + (output (buffer-string)))
\r
89 + (notmuch-check-exit-status status (cons notmuch-command args) output)
\r
92 (defun notmuch-version ()
\r
93 "Return a string with the notmuch version number."
\r
95 ;; Trim off the trailing newline.
\r
96 - (substring (shell-command-to-string
\r
97 - (concat notmuch-command " --version"))
\r
99 + (substring (notmuch-command-to-string "--version") 0 -1))
\r
100 (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
\r
102 (match-string 2 long-string)
\r
103 @@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
\r
104 (defun notmuch-config-get (item)
\r
105 "Return a value from the notmuch configuration."
\r
106 ;; Trim off the trailing newline
\r
107 - (substring (shell-command-to-string
\r
108 - (concat notmuch-command " config get " item))
\r
110 + (substring (notmuch-command-to-string "config" "get" item) 0 -1))
\r
112 (defun notmuch-database-path ()
\r
113 "Return the database.path value from the notmuch configuration."
\r