1 Return-Path: <amdragon@mit.edu>
\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 1FF9B431FC7
\r
6 for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:16:50 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 K2q9j2y5TfW6 for <notmuch@notmuchmail.org>;
\r
16 Thu, 20 Feb 2014 11:16:46 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id C2CC3431FBF
\r
22 for <notmuch@notmuchmail.org>; Thu, 20 Feb 2014 11:16:46 -0800 (PST)
\r
23 X-AuditID: 1209190e-f79ee6d000000c40-0b-5306549e3659
\r
24 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 6F.61.03136.E9456035; Thu, 20 Feb 2014 14:16:46 -0500 (EST)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s1KJGhK2005934;
\r
31 Thu, 20 Feb 2014 14:16:43 -0500
\r
32 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])
\r
33 (authenticated bits=0)
\r
34 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
35 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1KJGf42012829
\r
36 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
37 Thu, 20 Feb 2014 14:16:42 -0500
\r
38 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
39 (envelope-from <amdragon@mit.edu>)
\r
40 id 1WGZ6v-0004Z8-1q; Thu, 20 Feb 2014 14:16:41 -0500
\r
41 From: Austin Clements <amdragon@MIT.EDU>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 2/4] emacs: Fix exception when fetching empty or unconfigured
\r
45 Date: Thu, 20 Feb 2014 14:16:35 -0500
\r
46 Message-Id: <1392923797-17045-3-git-send-email-amdragon@mit.edu>
\r
47 X-Mailer: git-send-email 1.8.4.rc3
\r
48 In-Reply-To: <1392923797-17045-1-git-send-email-amdragon@mit.edu>
\r
49 References: <1392923797-17045-1-git-send-email-amdragon@mit.edu>
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixG6nrjsvhC3YoOGNosXrBZPYLK7fnMns
\r
52 wOSxem0ni8ezVbeYA5iiuGxSUnMyy1KL9O0SuDLOnZ7NWLCYu2LLluVsDYydnF2MnBwSAiYS
\r
53 G3+8Y4ewxSQu3FvP1sXIxSEkMJtJYt7up1DORkaJRf1LWSCcI0wS93+3QGXmMkrsXfcIrJ9N
\r
54 QENi2/7ljCC2iIC0xM67s1lBbGYBG4nNHx+DxYUFwiROX5rDAmKzCKhKbPx9hgnE5hVwkFi5
\r
55 cyYLxB1KEgtPbQPr5RRwlFja/wHI5gBa5iDRuVVnAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJ
\r
56 eXmpRbrGermZJXqpKaWbGEGhxCnJt4Px60GlQ4wCHIxKPLwnpdiChVgTy4orcw8xSnIwKYny
\r
57 rggACvEl5adUZiQWZ8QXleakFh9ilOBgVhLhbbIByvGmJFZWpRblw6SkOViUxHlrLX4FCQmk
\r
58 J5akZqemFqQWwWRlODiUJHjnBQM1ChalpqdWpGXmlCCkmTg4QYbzAA2PDAIZXlyQmFucmQ6R
\r
59 P8WoKCXO+xQkIQCSyCjNg+uFxforRnGgV4R5E0FW8ADTBFz3K6DBTECDSzayggwuSURISTUw
\r
60 ztuzYYZRa3/J2izO29tCZZ67ivN5K5yaeZgvzPRW3UKP7CXnDZ7r7922Nor53MOsjmtKMkvV
\r
61 NFnC8wWX6bxelGS0RfCe8pYv17x0Dq6wO67evN5CR4/LLoul95GwgVlffO31XsvNUlM/ab7c
\r
62 uUidp+7tbW+95N7vuu/3LZXPfLT52o8zv9bOU2Ipzkg01GIuKk4EAMGYhbfQAgAA
\r
63 Cc: bjonnh-nm@bjonnh.net
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Thu, 20 Feb 2014 19:16:50 -0000
\r
78 When "notmuch config" is called with the name of an empty or
\r
79 unconfigured setting, it prints nothing (not even a new line).
\r
80 Previously, `notmuch-config-get' assumed it would always print a
\r
81 newline. As a result, when `notmuch-config-get' was called with the
\r
82 name of an empty of unconfigured setting, it would attempt to
\r
83 (substring "" 0 -1) to strip the newline, which would fail with a
\r
84 (args-out-of-range "" 0 -1) exception.
\r
86 Fix this by only stripping the newline if there actually is one.
\r
88 emacs/notmuch-lib.el | 9 +++++++--
\r
89 1 file changed, 7 insertions(+), 2 deletions(-)
\r
91 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
92 index fa35fa9..09110b5 100644
\r
93 --- a/emacs/notmuch-lib.el
\r
94 +++ b/emacs/notmuch-lib.el
\r
95 @@ -198,8 +198,13 @@ on the command line, and then retry your notmuch command")))
\r
97 (defun notmuch-config-get (item)
\r
98 "Return a value from the notmuch configuration."
\r
99 - ;; Trim off the trailing newline
\r
100 - (substring (notmuch-command-to-string "config" "get" item) 0 -1))
\r
101 + (let* ((val (notmuch-command-to-string "config" "get" item))
\r
102 + (len (length val)))
\r
103 + ;; Trim off the trailing newline (if the value is empty or not
\r
104 + ;; configured, there will be no newline)
\r
105 + (if (and (> len 0) (= (aref val (- len 1)) ?\n))
\r
106 + (substring val 0 -1)
\r
109 (defun notmuch-database-path ()
\r
110 "Return the database.path value from the notmuch configuration."
\r