--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\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 8F466431FDB\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Mar 2015 13:53:57 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 QdS02rtIEFXh for <notmuch@notmuchmail.org>;\r
+ Mon, 9 Mar 2015 13:53:55 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id D004D431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Mar 2015 13:53:51 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1YV4eY-00063o-So; Mon, 09 Mar 2015 20:51:54 +0000\r
+Received: (nullmailer pid 22322 invoked by uid 1000); Mon, 09 Mar 2015\r
+ 20:51:32 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Jani Nikula <jani@nikula.org>, David Bremner <david@tethera.net>,\r
+ notmuch@notmuchmail.org\r
+Subject: [Patch v2 2/2] CLI: make gpg binary used by libgmime configurable.\r
+Date: Mon, 9 Mar 2015 21:51:23 +0100\r
+Message-Id: <1425934283-22269-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425934283-22269-1-git-send-email-david@tethera.net>\r
+References: <87fv9givdr.fsf@nikula.org>\r
+ <1425934283-22269-1-git-send-email-david@tethera.net>\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: Mon, 09 Mar 2015 20:53:58 -0000\r
+\r
+Previously we set up a way for the top level notmuch command to choose\r
+which gpg binary was invoked by libgmime. In this commit we add the\r
+(mostly boilerplate) code to allow the notmuch-config command to read\r
+and write this path, and use it in the appropriate struct.\r
+---\r
+ doc/man1/notmuch-config.rst | 8 ++++++++\r
+ notmuch-client.h | 7 +++++++\r
+ notmuch-config.c | 35 ++++++++++++++++++++++++++++++++++-\r
+ notmuch-reply.c | 2 ++\r
+ notmuch-show.c | 2 ++\r
+ 5 files changed, 53 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
+index 2676a86..40c1272 100644\r
+--- a/doc/man1/notmuch-config.rst\r
++++ b/doc/man1/notmuch-config.rst\r
+@@ -125,6 +125,14 @@ The available configuration items are described below.\r
+ \r
+ Default: ``true``.\r
+ \r
++ **crypto.gpg_path**\r
++\r
++ Name (or full path) of gpg binary to use in verification and\r
++ decryption of PGP/MIME messages.\r
++ \r
++ Default: ``gpg``.\r
++\r
++\r
+ ENVIRONMENT\r
+ ===========\r
+ \r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index c25c4ea..fb3021c 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -279,6 +279,13 @@ notmuch_config_set_database_path (notmuch_config_t *config,\r
+ const char *database_path);\r
+ \r
+ const char *\r
++notmuch_config_get_crypto_gpg_path (notmuch_config_t *config);\r
++\r
++void\r
++notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,\r
++ const char *gpg_path);\r
++\r
++const char *\r
+ notmuch_config_get_user_name (notmuch_config_t *config);\r
+ \r
+ void\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index a564bca..2d5c297 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -101,12 +101,21 @@ static const char search_config_comment[] =\r
+ "\t\tsearch results by default. Using an excluded tag in a\n"\r
+ "\t\tquery will override that exclusion.\n";\r
+ \r
++static const char crypto_config_comment[] =\r
++ " Cryptography related configuration\n"\r
++ "\n"\r
++ " The following option is supported here:\n"\r
++ "\n"\r
++ "\tgpg_path\n"\r
++ "\t\tbinary name or full path to invoke gpg.\n";\r
++\r
+ struct _notmuch_config {\r
+ char *filename;\r
+ GKeyFile *key_file;\r
+ notmuch_bool_t is_new;\r
+ \r
+ char *database_path;\r
++ char *crypto_gpg_path;\r
+ char *user_name;\r
+ char *user_primary_email;\r
+ const char **user_other_email;\r
+@@ -244,6 +253,7 @@ notmuch_config_open (void *ctx,\r
+ int file_had_user_group;\r
+ int file_had_maildir_group;\r
+ int file_had_search_group;\r
++ int file_had_crypto_group;\r
+ \r
+ notmuch_config_t *config = talloc (ctx, notmuch_config_t);\r
+ if (config == NULL) {\r
+@@ -277,6 +287,7 @@ notmuch_config_open (void *ctx,\r
+ config->maildir_synchronize_flags = TRUE;\r
+ config->search_exclude_tags = NULL;\r
+ config->search_exclude_tags_length = 0;\r
++ config->crypto_gpg_path = NULL;\r
+ \r
+ if (! g_key_file_load_from_file (config->key_file,\r
+ config->filename,\r
+@@ -326,7 +337,7 @@ notmuch_config_open (void *ctx,\r
+ file_had_user_group = g_key_file_has_group (config->key_file, "user");\r
+ file_had_maildir_group = g_key_file_has_group (config->key_file, "maildir");\r
+ file_had_search_group = g_key_file_has_group (config->key_file, "search");\r
+-\r
++ file_had_crypto_group = g_key_file_has_group (config->key_file, "crypto");\r
+ \r
+ if (notmuch_config_get_database_path (config) == NULL) {\r
+ char *path = getenv ("MAILDIR");\r
+@@ -406,6 +417,10 @@ notmuch_config_open (void *ctx,\r
+ g_error_free (error);\r
+ }\r
+ \r
++ if (notmuch_config_get_crypto_gpg_path (config) == NULL) {\r
++ notmuch_config_set_crypto_gpg_path (config, "gpg");\r
++ }\r
++ \r
+ /* Whenever we know of configuration sections that don't appear in\r
+ * the configuration file, we add some comments to help the user\r
+ * understand what can be done. */\r
+@@ -433,6 +448,10 @@ notmuch_config_open (void *ctx,\r
+ g_key_file_set_comment (config->key_file, "search", NULL,\r
+ search_config_comment, NULL);\r
+ \r
++ if (! file_had_crypto_group)\r
++ g_key_file_set_comment (config->key_file, "crypto", NULL,\r
++ crypto_config_comment, NULL);\r
++\r
+ return config;\r
+ }\r
+ \r
+@@ -690,6 +709,20 @@ notmuch_config_set_search_exclude_tags (notmuch_config_t *config,\r
+ &(config->search_exclude_tags));\r
+ }\r
+ \r
++const char *\r
++notmuch_config_get_crypto_gpg_path (notmuch_config_t *config)\r
++{\r
++ return _config_get (config, &config->crypto_gpg_path, "crypto", "gpg_path");\r
++}\r
++\r
++void\r
++notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,\r
++ const char *gpg_path)\r
++{\r
++ _config_set (config, &config->crypto_gpg_path, "crypto", "gpg_path", gpg_path);\r
++}\r
++\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
+ * stderr and return 1. Otherwise, return 0.\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index e18370f..d51fdfc 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -822,6 +822,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
++ params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);\r
++\r
+ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+ NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))\r
+ return EXIT_FAILURE;\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d292f29..43bf71c 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1204,6 +1204,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
++ params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config);\r
++\r
+ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+ NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))\r
+ return EXIT_FAILURE;\r
+-- \r
+2.1.4\r
+\r