--- /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 olra.theworths.org (Postfix) with ESMTP id 95822431FDD\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:09:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id A8itxHlr638i for <notmuch@notmuchmail.org>;\r
+ Sun, 18 Aug 2013 11:09:21 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id D198A431FDB\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:09:20 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 07228100086;\r
+ Sun, 18 Aug 2013 21:09:16 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] cli: define config getters and setters using a macro\r
+In-Reply-To: <1376839205-5115-2-git-send-email-jani@nikula.org>\r
+References: <1376839205-5115-1-git-send-email-jani@nikula.org>\r
+ <1376839205-5115-2-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.16+3~g340c058 (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: Sun, 18 Aug 2013 21:09:15 +0300\r
+Message-ID: <m2zjse7tx0.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 18 Aug 2013 18:09:25 -0000\r
+\r
+On Sun, Aug 18 2013, Jani Nikula <jani@nikula.org> wrote:\r
+\r
+> There's plenty of duplicated code in defining the functions for config\r
+> get/set. Add macros to define the functions.\r
+>\r
+> ---\r
+>\r
+> This might be a bit too tricky for some people's tastes... let's see!\r
+> ;)\r
+\r
+Yes, a bit tricky. Nevertheless I like these...\r
+\r
+Additionally id:1376839205-5115-1-git-send-email-jani@nikula.org LGTM.\r
+\r
+Tomi\r
+\r
+\r
+> ---\r
+> notmuch-config.c | 141 ++++++++++++++----------------------------------------\r
+> 1 file changed, 37 insertions(+), 104 deletions(-)\r
+>\r
+> diff --git a/notmuch-config.c b/notmuch-config.c\r
+> index 305d213..fcee0fc 100644\r
+> --- a/notmuch-config.c\r
+> +++ b/notmuch-config.c\r
+> @@ -520,6 +520,18 @@ _config_set (notmuch_config_t *config, char **field,\r
+> *field = NULL;\r
+> }\r
+> \r
+> +#define DEFINE_CONFIG_GET(group, key) \\r
+> + const char * \\r
+> + notmuch_config_get_ ## group ## _ ## key (notmuch_config_t *config) { \\r
+> + return _config_get (config, &config->group ## _ ## key, #group, #key); \\r
+> + }\r
+> +\r
+> +#define DEFINE_CONFIG_SET(group, key) \\r
+> + void \\r
+> + notmuch_config_set_ ## group ## _ ## key (notmuch_config_t *config, const char *value) { \\r
+> + _config_set (config, &config->group ## _ ## key, #group, #key, value); \\r
+> + }\r
+> +\r
+> static const char **\r
+> _config_get_list (notmuch_config_t *config,\r
+> const char *section, const char *key,\r
+> @@ -562,112 +574,33 @@ _config_set_list (notmuch_config_t *config,\r
+> *config_var = NULL;\r
+> }\r
+> \r
+> -const char *\r
+> -notmuch_config_get_database_path (notmuch_config_t *config)\r
+> -{\r
+> - return _config_get (config, &config->database_path, "database", "path");\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_database_path (notmuch_config_t *config,\r
+> - const char *database_path)\r
+> -{\r
+> - _config_set (config, &config->database_path, "database", "path", database_path);\r
+> -}\r
+> -\r
+> -const char *\r
+> -notmuch_config_get_user_name (notmuch_config_t *config)\r
+> -{\r
+> - return _config_get (config, &config->user_name, "user", "name");\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_user_name (notmuch_config_t *config,\r
+> - const char *user_name)\r
+> -{\r
+> - _config_set (config, &config->user_name, "user", "name", user_name);\r
+> -}\r
+> -\r
+> -const char *\r
+> -notmuch_config_get_user_primary_email (notmuch_config_t *config)\r
+> -{\r
+> - return _config_get (config, &config->user_primary_email, "user", "primary_email");\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_user_primary_email (notmuch_config_t *config,\r
+> - const char *primary_email)\r
+> -{\r
+> - _config_set (config, &config->user_primary_email, "user", "primary_email", primary_email);\r
+> -}\r
+> -\r
+> -const char **\r
+> -notmuch_config_get_user_other_email (notmuch_config_t *config, size_t *length)\r
+> -{\r
+> - return _config_get_list (config, "user", "other_email",\r
+> - &(config->user_other_email),\r
+> - &(config->user_other_email_length), length);\r
+> -}\r
+> -\r
+> -const char **\r
+> -notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)\r
+> -{\r
+> - return _config_get_list (config, "new", "tags",\r
+> - &(config->new_tags),\r
+> - &(config->new_tags_length), length);\r
+> -}\r
+> -\r
+> -const char **\r
+> -notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)\r
+> -{\r
+> - return _config_get_list (config, "new", "ignore",\r
+> - &(config->new_ignore),\r
+> - &(config->new_ignore_length), length);\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_user_other_email (notmuch_config_t *config,\r
+> - const char *list[],\r
+> - size_t length)\r
+> -{\r
+> - _config_set_list (config, "user", "other_email", list, length,\r
+> - &(config->user_other_email));\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_new_tags (notmuch_config_t *config,\r
+> - const char *list[],\r
+> - size_t length)\r
+> -{\r
+> - _config_set_list (config, "new", "tags", list, length,\r
+> - &(config->new_tags));\r
+> -}\r
+> -\r
+> -void\r
+> -notmuch_config_set_new_ignore (notmuch_config_t *config,\r
+> - const char *list[],\r
+> - size_t length)\r
+> -{\r
+> - _config_set_list (config, "new", "ignore", list, length,\r
+> - &(config->new_ignore));\r
+> -}\r
+> +#define DEFINE_CONFIG_GET_LIST(group, key) \\r
+> + const char ** \\r
+> + notmuch_config_get_ ## group ## _ ## key (notmuch_config_t *config, size_t *length) { \\r
+> + return _config_get_list (config, #group, #key, &config->group ## _ ## key, &config->group ## _ ## key ## _ ## length, length); \\r
+> + }\r
+> \r
+> -const char **\r
+> -notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)\r
+> -{\r
+> - return _config_get_list (config, "search", "exclude_tags",\r
+> - &(config->search_exclude_tags),\r
+> - &(config->search_exclude_tags_length), length);\r
+> -}\r
+> +#define DEFINE_CONFIG_SET_LIST(group, key) \\r
+> + void \\r
+> + notmuch_config_set_ ## group ## _ ## key (notmuch_config_t *config, const char *list[], size_t length) { \\r
+> + _config_set_list (config, #group, #key, list, length, &config->group ## _ ## key); \\r
+> + }\r
+> \r
+> -void\r
+> -notmuch_config_set_search_exclude_tags (notmuch_config_t *config,\r
+> - const char *list[],\r
+> - size_t length)\r
+> -{\r
+> - _config_set_list (config, "search", "exclude_tags", list, length,\r
+> - &(config->search_exclude_tags));\r
+> -}\r
+> +DEFINE_CONFIG_GET(database, path);\r
+> +DEFINE_CONFIG_SET(database, path);\r
+> +DEFINE_CONFIG_GET(user, name);\r
+> +DEFINE_CONFIG_SET(user, name);\r
+> +DEFINE_CONFIG_GET(user, primary_email);\r
+> +DEFINE_CONFIG_SET(user, primary_email);\r
+> +\r
+> +DEFINE_CONFIG_GET_LIST(user, other_email);\r
+> +DEFINE_CONFIG_SET_LIST(user, other_email);\r
+> +DEFINE_CONFIG_GET_LIST(new, tags);\r
+> +DEFINE_CONFIG_SET_LIST(new, tags);\r
+> +DEFINE_CONFIG_GET_LIST(new, ignore);\r
+> +DEFINE_CONFIG_SET_LIST(new, ignore);\r
+> +DEFINE_CONFIG_GET_LIST(search, exclude_tags);\r
+> +DEFINE_CONFIG_SET_LIST(search, exclude_tags);\r
+> \r
+> /* Given a configuration item of the form <group>.<key> return the\r
+> * component group and key. If any error occurs, print a message on\r
+> -- \r
+> 1.7.10.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r