1 Return-Path: <bremner@tesseract.cs.unb.ca>
\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 arlo.cworth.org (Postfix) with ESMTP id 3075E6DE02DA
\r
6 for <notmuch@notmuchmail.org>; Sat, 26 Mar 2016 11:23:25 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.02 tagged_above=-999 required=5 tests=[AWL=-0.021,
\r
12 HEADER_FROM_DIFFERENT_DOMAINS=0.001] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id UhMcAWZWtqbY for <notmuch@notmuchmail.org>;
\r
16 Sat, 26 Mar 2016 11:23:15 -0700 (PDT)
\r
17 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id 754E86DE02A9
\r
19 for <notmuch@notmuchmail.org>; Sat, 26 Mar 2016 11:23:15 -0700 (PDT)
\r
20 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)
\r
21 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
22 id 1ajsTO-0000uK-M4; Sat, 26 Mar 2016 13:58:06 -0400
\r
23 Received: (nullmailer pid 8810 invoked by uid 1000);
\r
24 Sat, 26 Mar 2016 17:57:27 -0000
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [Patch v2 04/13] lib/cli: add library API / CLI for compile time
\r
29 Date: Sat, 26 Mar 2016 14:57:14 -0300
\r
30 Message-Id: <1459015043-8460-5-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.6.4
\r
32 In-Reply-To: <1459015043-8460-1-git-send-email-david@tethera.net>
\r
33 References: <1459015043-8460-1-git-send-email-david@tethera.net>
\r
35 Content-Type: text/plain; charset=UTF-8
\r
36 Content-Transfer-Encoding: 8bit
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.20
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Sat, 26 Mar 2016 18:23:25 -0000
\r
51 This is intentionally low tech; if we have more than two options it may
\r
52 make sense to build up what infrastructure is provided.
\r
54 doc/man1/notmuch-config.rst | 5 +++++
\r
55 lib/Makefile.local | 1 +
\r
56 lib/notmuch.h | 10 +++++++++
\r
57 lib/options.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
\r
58 notmuch-config.c | 20 ++++++++++++++++++
\r
59 test/T030-config.sh | 6 ++++--
\r
60 test/T040-setup.sh | 6 ++++--
\r
61 test/test-lib.sh | 6 ++++++
\r
62 8 files changed, 100 insertions(+), 4 deletions(-)
\r
63 create mode 100644 lib/options.c
\r
65 diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
\r
66 index 40c1272..150d764 100644
\r
67 --- a/doc/man1/notmuch-config.rst
\r
68 +++ b/doc/man1/notmuch-config.rst
\r
69 @@ -132,6 +132,11 @@ The available configuration items are described below.
\r
73 + **options.<name>**
\r
75 + Compile time option <name>. Current possibilities include
\r
76 + "compact" (see **notmuch-compact(1)**)
\r
77 + and "field_processor" (see **notmuch-search-terms(7)**).
\r
81 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
82 index 3a07090..4ad0158 100644
\r
83 --- a/lib/Makefile.local
\r
84 +++ b/lib/Makefile.local
\r
85 @@ -39,6 +39,7 @@ libnotmuch_c_srcs = \
\r
86 $(dir)/message-file.c \
\r
89 + $(dir)/options.c \
\r
92 libnotmuch_cxx_srcs = \
\r
93 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
94 index cb46fc0..b29dd5f 100644
\r
97 @@ -1838,6 +1838,16 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
\r
99 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
\r
102 + NOTMUCH_OPTION_COMPACT = 1,
\r
103 + NOTMUCH_OPTION_FIELD_PROCESSOR = 2
\r
104 +} notmuch_option_t;
\r
107 +notmuch_options_present (notmuch_option_t mask);
\r
110 +notmuch_options_get (const char *name);
\r
114 diff --git a/lib/options.c b/lib/options.c
\r
115 new file mode 100644
\r
116 index 0000000..4e15d92
\r
118 +++ b/lib/options.c
\r
120 +/* notmuch - Not much of an email program, (just index and search)
\r
122 + * Copyright © 2016 David Bremner
\r
124 + * This program is free software: you can redistribute it and/or modify
\r
125 + * it under the terms of the GNU General Public License as published by
\r
126 + * the Free Software Foundation, either version 3 of the License, or
\r
127 + * (at your option) any later version.
\r
129 + * This program is distributed in the hope that it will be useful,
\r
130 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
131 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
132 + * GNU General Public License for more details.
\r
134 + * You should have received a copy of the GNU General Public License
\r
135 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
137 + * Author: David Bremner <david@tethera.net>
\r
140 +#include "notmuch.h"
\r
141 +#include "notmuch-private.h"
\r
144 +notmuch_options_present (notmuch_option_t mask)
\r
146 + notmuch_option_t present = 0;
\r
148 +#if HAVE_XAPIAN_COMPACT
\r
149 + present |= NOTMUCH_OPTION_COMPACT;
\r
152 +#if HAVE_XAPIAN_COMPACT
\r
153 + present |= NOTMUCH_OPTION_FIELD_PROCESSOR;
\r
156 + return (mask & present) != 0;
\r
161 +notmuch_options_get (const char *name) {
\r
162 + if (STRNCMP_LITERAL (name, "compact") == 0) {
\r
163 + return notmuch_options_present (NOTMUCH_OPTION_COMPACT);
\r
164 + } else if (STRNCMP_LITERAL (name, "field_processor") == 0) {
\r
165 + return notmuch_options_present (NOTMUCH_OPTION_FIELD_PROCESSOR);
\r
170 diff --git a/notmuch-config.c b/notmuch-config.c
\r
171 index d252bb2..cfc549d 100644
\r
172 --- a/notmuch-config.c
\r
173 +++ b/notmuch-config.c
\r
174 @@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)
\r
178 +#define OPTION_PREFIX "options."
\r
181 notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
183 @@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
184 tags = notmuch_config_get_new_tags (config, &length);
\r
185 for (i = 0; i < length; i++)
\r
186 printf ("%s\n", tags[i]);
\r
187 + } else if (STRNCMP_LITERAL (item, OPTION_PREFIX) == 0) {
\r
189 + notmuch_options_get (item + strlen (OPTION_PREFIX)) ? "true" : "false");
\r
193 @@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
197 + if (STRNCMP_LITERAL (item, OPTION_PREFIX) == 0) {
\r
198 + fprintf (stderr, "Error: read only option: %s\n", item);
\r
202 if (_item_split (item, &group, &key))
\r
205 @@ -830,6 +840,15 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
206 return notmuch_config_save (config);
\r
211 +_notmuch_config_list_options () {
\r
212 + printf("options.compact=%s\n",
\r
213 + notmuch_options_present(NOTMUCH_OPTION_COMPACT) ? "true" : "false");
\r
214 + printf("options.field_processor=%s\n",
\r
215 + notmuch_options_present(NOTMUCH_OPTION_FIELD_PROCESSOR) ? "true" : "false");
\r
219 notmuch_config_command_list (notmuch_config_t *config)
\r
221 @@ -865,6 +884,7 @@ notmuch_config_command_list (notmuch_config_t *config)
\r
223 g_strfreev (groups);
\r
225 + _notmuch_config_list_options ();
\r
229 diff --git a/test/T030-config.sh b/test/T030-config.sh
\r
230 index f404908..c37ba21 100755
\r
231 --- a/test/T030-config.sh
\r
232 +++ b/test/T030-config.sh
\r
233 @@ -44,7 +44,7 @@ test_expect_equal "$(notmuch config get foo.nonexistent)" ""
\r
235 test_begin_subtest "List all items"
\r
236 notmuch config set database.path "/canonical/path"
\r
237 -output=$(notmuch config list)
\r
238 +output=$(notmuch config list | notmuch_options_sanitize)
\r
239 test_expect_equal "$output" "\
\r
240 database.path=/canonical/path
\r
241 user.name=Notmuch Test Suite
\r
242 @@ -56,7 +56,9 @@ search.exclude_tags=
\r
243 maildir.synchronize_flags=true
\r
244 crypto.gpg_path=gpg
\r
245 foo.string=this is another string value
\r
246 -foo.list=this;is another;list value;"
\r
247 +foo.list=this;is another;list value;
\r
248 +options.compact=something
\r
249 +options.field_processor=something"
\r
251 test_begin_subtest "Top level --config=FILE option"
\r
252 cp "${NOTMUCH_CONFIG}" alt-config
\r
253 diff --git a/test/T040-setup.sh b/test/T040-setup.sh
\r
254 index cf0c00b..5db03a6 100755
\r
255 --- a/test/T040-setup.sh
\r
256 +++ b/test/T040-setup.sh
\r
257 @@ -19,7 +19,7 @@ another.suite@example.com
\r
261 -output=$(notmuch --config=new-notmuch-config config list)
\r
262 +output=$(notmuch --config=new-notmuch-config config list | notmuch_options_sanitize)
\r
263 test_expect_equal "$output" "\
\r
264 database.path=/path/to/maildir
\r
265 user.name=Test Suite
\r
266 @@ -29,6 +29,8 @@ new.tags=foo;bar;
\r
268 search.exclude_tags=baz;
\r
269 maildir.synchronize_flags=true
\r
270 -crypto.gpg_path=gpg"
\r
271 +crypto.gpg_path=gpg
\r
272 +options.compact=something
\r
273 +options.field_processor=something"
\r
276 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
277 index cc08a98..49e6f40 100644
\r
278 --- a/test/test-lib.sh
\r
279 +++ b/test/test-lib.sh
\r
280 @@ -733,6 +733,12 @@ notmuch_uuid_sanitize ()
\r
282 sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'
\r
285 +notmuch_options_sanitize ()
\r
287 + sed 's/^options[.]\(.*\)=.*$/options.\1=something/'
\r
290 # End of notmuch helper functions
\r
292 # Use test_set_prereq to tell that a particular prerequisite is available.
\r