--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id DBF046DE02AC\r
+ for <notmuch@notmuchmail.org>; Wed, 27 Apr 2016 10:47:23 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.608\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.608 tagged_above=-999 required=5 tests=[AWL=-0.044,\r
+ SPF_NEUTRAL=0.652] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Q_HN8Fs2LH8l for <notmuch@notmuchmail.org>;\r
+ Wed, 27 Apr 2016 10:47:13 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 760E56DE01D0\r
+ for <notmuch@notmuchmail.org>; Wed, 27 Apr 2016 10:47:12 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 925CC100063;\r
+ Wed, 27 Apr 2016 20:47:05 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [Patch v2 04/13] lib/cli: add library API / CLI for compile time\r
+ options\r
+In-Reply-To: <1459015043-8460-5-git-send-email-david@tethera.net>\r
+References: <1459015043-8460-1-git-send-email-david@tethera.net>\r
+ <1459015043-8460-5-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.22+7~g2ab49fe (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 27 Apr 2016 20:47:04 +0300\r
+Message-ID: <m27ffjvt9j.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 27 Apr 2016 17:47:24 -0000\r
+\r
+On Sat, Mar 26 2016, David Bremner <david@tethera.net> wrote:\r
+\r
+> This is intentionally low tech; if we have more than two options it may\r
+> make sense to build up what infrastructure is provided.\r
+\r
+2 quick notes for this patch -- since it has been like a month when I\r
+looked this it takes time to get re-acquainted to the series again\r
+\r
+...IMO this compile time "options" feels a bit odd; what options those are\r
+if those are not options (but fixed things on what is available on the\r
+underlying libraries). something like "features" would be a little less\r
+odd (if there were no "database features" there ;/)\r
+\r
+another thing is that these fixed things that were resolved by compile time=\r
+=20\r
+is (re-)checked in compile time. instead of that just the=20\r
+HAVE_XAPIAN_COMPACT and HAVE_XAPIAN_FIELD_PROCESSOR could be used\r
+\r
+... like:=20\r
+\r
+notmuch_bool_t\r
+notmuch_options_get (const char *name) {\r
+ if (STRNCMP_LITERAL (name, "compact") =3D=3D 0) {\r
+ return HAVE_XAPIAN_COMPACT;\r
+ // or return HAVE_XAPIAN_COMPACT? TRUE: FALSE;\r
+ // or return !! HAVE_XAPIAN_COMPACT;\r
+ } else if (STRNCMP_LITERAL (name, "field_processor") =3D=3D 0) {\r
+ return HAVE_XAPIAN_FIELD_PROCESSOR;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+}\r
+\r
+... note: if this notmuch_options_present () function prevails, fix\r
+the later #if check ;D\r
+\r
+... and\r
+\r
+void\r
+_notmuch_config_list_options () {\r
+ printf("options.compact=3D%s\n",\r
+ HAVE_XAPIAN_COMPACT ? "true" : "false");\r
+ printf("options.field_processor=3D%s\n",\r
+ HAVE_XAPIAN_FIELD_PROCESSOR ? "true" : "false");\r
+}\r
+\r
+(kept the 'options' naming and prefix in this context)\r
+\r
+otoh, all this "options" reading using notmuch config interface could\r
+be pos^H^H^H^H put into another series and this naming thing could be\r
+resolved there (proviced that these #if HAVE_XAPIAN ... #endif constructs\r
+can be used conveniently here)\r
+\r
+this is how these things look to me now; as usual i may not have=20\r
+caught all of the considerations here.\r
+\r
+Tomi\r
+\r
+\r
+> ---\r
+> doc/man1/notmuch-config.rst | 5 +++++\r
+> lib/Makefile.local | 1 +\r
+> lib/notmuch.h | 10 +++++++++\r
+> lib/options.c | 50 +++++++++++++++++++++++++++++++++++++++=\r
+++++++\r
+> notmuch-config.c | 20 ++++++++++++++++++\r
+> test/T030-config.sh | 6 ++++--\r
+> test/T040-setup.sh | 6 ++++--\r
+> test/test-lib.sh | 6 ++++++\r
+> 8 files changed, 100 insertions(+), 4 deletions(-)\r
+> create mode 100644 lib/options.c\r
+>\r
+> diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
+> index 40c1272..150d764 100644\r
+> --- a/doc/man1/notmuch-config.rst\r
+> +++ b/doc/man1/notmuch-config.rst\r
+> @@ -132,6 +132,11 @@ The available configuration items are described belo=\r
+w.\r
+>=20=20=20=20=20=20\r
+> Default: ``gpg``.\r
+>=20=20\r
+> + **options.<name>**\r
+> +\r
+> + Compile time option <name>. Current possibilities include\r
+> + "compact" (see **notmuch-compact(1)**)\r
+> + and "field_processor" (see **notmuch-search-terms(7)**).\r
+>=20=20\r
+> ENVIRONMENT\r
+> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r
+> diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+> index 3a07090..4ad0158 100644\r
+> --- a/lib/Makefile.local\r
+> +++ b/lib/Makefile.local\r
+> @@ -39,6 +39,7 @@ libnotmuch_c_srcs =3D \\r
+> $(dir)/message-file.c \\r
+> $(dir)/messages.c \\r
+> $(dir)/sha1.c \\r
+> + $(dir)/options.c \\r
+> $(dir)/tags.c\r
+>=20=20\r
+> libnotmuch_cxx_srcs =3D \\r
+> diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> index cb46fc0..b29dd5f 100644\r
+> --- a/lib/notmuch.h\r
+> +++ b/lib/notmuch.h\r
+> @@ -1838,6 +1838,16 @@ notmuch_filenames_move_to_next (notmuch_filenames_=\r
+t *filenames);\r
+> void\r
+> notmuch_filenames_destroy (notmuch_filenames_t *filenames);\r
+>=20=20\r
+> +typedef enum {\r
+> + NOTMUCH_OPTION_COMPACT =3D 1,\r
+> + NOTMUCH_OPTION_FIELD_PROCESSOR =3D 2\r
+> +} notmuch_option_t;\r
+> +\r
+> +notmuch_bool_t\r
+> +notmuch_options_present (notmuch_option_t mask);\r
+> +\r
+> +notmuch_bool_t\r
+> +notmuch_options_get (const char *name);\r
+> /* @} */\r
+>=20=20\r
+> NOTMUCH_END_DECLS\r
+> diff --git a/lib/options.c b/lib/options.c\r
+> new file mode 100644\r
+> index 0000000..4e15d92\r
+> --- /dev/null\r
+> +++ b/lib/options.c\r
+> @@ -0,0 +1,50 @@\r
+> +/* notmuch - Not much of an email program, (just index and search)\r
+> + *\r
+> + * Copyright =C2=A9 2016 David Bremner\r
+> + *\r
+> + * This program is free software: you can redistribute it and/or modify\r
+> + * it under the terms of the GNU General Public License as published by\r
+> + * the Free Software Foundation, either version 3 of the License, or\r
+> + * (at your option) any later version.\r
+> + *\r
+> + * This program is distributed in the hope that it will be useful,\r
+> + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+> + * GNU General Public License for more details.\r
+> + *\r
+> + * You should have received a copy of the GNU General Public License\r
+> + * along with this program. If not, see http://www.gnu.org/licenses/ .\r
+> + *\r
+> + * Author: David Bremner <david@tethera.net>\r
+> + */\r
+> +\r
+> +#include "notmuch.h"\r
+> +#include "notmuch-private.h"\r
+> +\r
+> +notmuch_bool_t\r
+> +notmuch_options_present (notmuch_option_t mask)\r
+> +{\r
+> + notmuch_option_t present =3D 0;\r
+> +\r
+> +#if HAVE_XAPIAN_COMPACT\r
+> + present |=3D NOTMUCH_OPTION_COMPACT;\r
+> +#endif\r
+> +\r
+> +#if HAVE_XAPIAN_COMPACT\r
+> + present |=3D NOTMUCH_OPTION_FIELD_PROCESSOR;\r
+> +#endif\r
+> +\r
+> + return (mask & present) !=3D 0;\r
+> +\r
+> +}\r
+> +\r
+> +notmuch_bool_t\r
+> +notmuch_options_get (const char *name) {\r
+> + if (STRNCMP_LITERAL (name, "compact") =3D=3D 0) {\r
+> + return notmuch_options_present (NOTMUCH_OPTION_COMPACT);\r
+> + } else if (STRNCMP_LITERAL (name, "field_processor") =3D=3D 0) {\r
+> + return notmuch_options_present (NOTMUCH_OPTION_FIELD_PROCESSOR);\r
+> + } else {\r
+> + return FALSE;\r
+> + }\r
+> +}\r
+> diff --git a/notmuch-config.c b/notmuch-config.c\r
+> index d252bb2..cfc549d 100644\r
+> --- a/notmuch-config.c\r
+> +++ b/notmuch-config.c\r
+> @@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)\r
+> return 0;\r
+> }\r
+>=20=20\r
+> +#define OPTION_PREFIX "options."\r
+> +\r
+> static int\r
+> notmuch_config_command_get (notmuch_config_t *config, char *item)\r
+> {\r
+> @@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config,=\r
+ char *item)\r
+> tags =3D notmuch_config_get_new_tags (config, &length);\r
+> for (i =3D 0; i < length; i++)\r
+> printf ("%s\n", tags[i]);\r
+> + } else if (STRNCMP_LITERAL (item, OPTION_PREFIX) =3D=3D 0) {\r
+> + printf ("%s\n",\r
+> + notmuch_options_get (item + strlen (OPTION_PREFIX)) ? "true" : "=\r
+false");\r
+> } else {\r
+> char **value;\r
+> size_t i, length;\r
+> @@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config=\r
+, char *item, int argc, char\r
+> {\r
+> char *group, *key;\r
+>=20=20\r
+> + if (STRNCMP_LITERAL (item, OPTION_PREFIX) =3D=3D 0) {\r
+> + fprintf (stderr, "Error: read only option: %s\n", item);\r
+> + return 1;\r
+> + }\r
+> +\r
+> if (_item_split (item, &group, &key))\r
+> return 1;\r
+>=20=20\r
+> @@ -830,6 +840,15 @@ notmuch_config_command_set (notmuch_config_t *config=\r
+, char *item, int argc, char\r
+> return notmuch_config_save (config);\r
+> }\r
+>=20=20\r
+> +static\r
+> +void\r
+> +_notmuch_config_list_options () {\r
+> + printf("options.compact=3D%s\n",\r
+> + notmuch_options_present(NOTMUCH_OPTION_COMPACT) ? "true" : "false");\r
+> + printf("options.field_processor=3D%s\n",\r
+> + notmuch_options_present(NOTMUCH_OPTION_FIELD_PROCESSOR) ? "true" : "=\r
+false");\r
+> +}\r