--- /dev/null
+Return-Path: <jani@nikula.org>\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 F037B421177\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 08:20:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 LJ-9KPbXPW4G for <notmuch@notmuchmail.org>;\r
+ Sun, 18 Aug 2013 08:20:06 -0700 (PDT)\r
+Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com\r
+ [209.85.214.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 25838429E59\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 08:20:06 -0700 (PDT)\r
+Received: by mail-bk0-f51.google.com with SMTP id mx10so1111067bkb.38\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 08:20:04 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=dX/jB0P4THWXkMen1TrH0kki1cbjh3Wg7fyJpyBuGWA=;\r
+ b=IYbdtoUmwccyBn7SFM/Xi0ns+bkrtEvfdFRF1j+ssosy4xjHFQya2sQherIy9U8pX/\r
+ oja6zKhPB6O0ozpyY6FOmUKA/cY4ZC+h2TmYpoiNcq8M67p7ObTDt525DVEc+RlH9YxX\r
+ MA7m6zNuKGJmhOps4W+ne8fk2ZkiGRBMLqfOeueqswpC/VLRft2w6adUPWUM8LKybXw0\r
+ 1dOqOgY9dwjR+MLAtNKXcB2xvL5p3oOwGkKsIy+z159JupVIq9ivigW/tlZ8jkALYQcF\r
+ oIIbMDz3Cnyszv3nRG1o7Tn0bbllmHlK7RfHqvinjPY7hMRY9n6J64JVw0sQTo5bQqK/\r
+ Mplg==\r
+X-Gm-Message-State:\r
+ ALoCoQnLCgoZfghpOR3oXcPaw/+CHM9oMNr1BX5I/kUOLOP14X0XhKkhbs4AdGH5hP8CvhKs87MF\r
+X-Received: by 10.205.10.132 with SMTP id pa4mr6969943bkb.15.1376839204800;\r
+ Sun, 18 Aug 2013 08:20:04 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id nv4sm949614bkb.3.1969.12.31.16.00.00\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 18 Aug 2013 08:20:04 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] cli: define config getters and setters using a macro\r
+Date: Sun, 18 Aug 2013 18:20:05 +0300\r
+Message-Id: <1376839205-5115-2-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1376839205-5115-1-git-send-email-jani@nikula.org>\r
+References: <1376839205-5115-1-git-send-email-jani@nikula.org>\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 15:20:12 -0000\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
+ 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