[PATCH 1/4] Add user.other_name property to associate names with other_email.

Subject: [PATCH 1/4] Add user.other_name property to associate names with other_email.

Date: Tue, 9 Aug 2016 16:55:15 -0400

To: notmuch@notmuchmail.org

Cc:

From: Shea Levy


Entries are paired with the email address at the same index in
other_email. To use user.name for a given other_email, leave that
entry blank or leave user.other_name shorter than the relevant index
altogether.
---
 notmuch-client.h |  9 +++++++++
 notmuch-config.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/notmuch-client.h b/notmuch-client.h
index ebc092b..69c83a2 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -304,6 +304,15 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,
 				     size_t length);
 
 const char **
+notmuch_config_get_user_other_name (notmuch_config_t *config,
+				    size_t *length);
+
+void
+notmuch_config_set_user_other_name (notmuch_config_t *config,
+				    const char *other_name[],
+				    size_t length);
+
+const char **
 notmuch_config_get_new_tags (notmuch_config_t *config,
 			     size_t *length);
 void
diff --git a/notmuch-config.c b/notmuch-config.c
index e5d42a0..4ac16b7 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -63,6 +63,8 @@ static const char user_config_comment[] =
     "\tprimary_email	Your primary email address.\n"
     "\tother_email	A list (separated by ';') of other email addresses\n"
     "\t		at which you receive email.\n"
+    "\tother_name	A list (separated by ';') of names corresponding to\n"
+    "\t 	other_email addresses. Leave an entry blank to use default\n"
     "\n"
     " Notmuch will use the various email addresses configured here when\n"
     " formatting replies. It will avoid including your own addresses in the\n"
@@ -120,6 +122,8 @@ struct _notmuch_config {
     char *user_primary_email;
     const char **user_other_email;
     size_t user_other_email_length;
+    const char **user_other_name;
+    size_t user_other_name_length;
     const char **new_tags;
     size_t new_tags_length;
     const char **new_ignore;
@@ -237,6 +241,8 @@ get_username_from_passwd_file (void *ctx)
  *
  *		user_other_email:	Not set.
  *
+ *		user_other_name:	Not set.
+ *
  *	The default configuration also contains comments to guide the
  *	user in editing the file directly.
  */
@@ -280,6 +286,8 @@ notmuch_config_open (void *ctx,
     config->user_primary_email = NULL;
     config->user_other_email = NULL;
     config->user_other_email_length = 0;
+    config->user_other_name = NULL;
+    config->user_other_name_length = 0;
     config->new_tags = NULL;
     config->new_tags_length = 0;
     config->new_ignore = NULL;
@@ -674,6 +682,23 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,
 		     &(config->user_other_email));
 }
 
+const char **
+notmuch_config_get_user_other_name (notmuch_config_t *config, size_t *length)
+{
+    return _config_get_list (config, "user", "other_name",
+			     &(config->user_other_name),
+			     &(config->user_other_name_length), length);
+}
+
+void
+notmuch_config_set_user_other_name (notmuch_config_t *config,
+				    const char *list[],
+				    size_t length)
+{
+    _config_set_list (config, "user", "other_name", list, length,
+		     &(config->user_other_name));
+}
+
 void
 notmuch_config_set_new_tags (notmuch_config_t *config,
 				     const char *list[],
@@ -790,6 +815,13 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
 	other_email = notmuch_config_get_user_other_email (config, &length);
 	for (i = 0; i < length; i++)
 	    printf ("%s\n", other_email[i]);
+    } else if (strcmp(item, "user.other_name") == 0) {
+	const char **other_name;
+	size_t i, length;
+
+	other_name = notmuch_config_get_user_other_name (config, &length);
+	for (i = 0; i < length; i++)
+	    printf ("%s\n", other_name[i]);
     } else if (strcmp(item, "new.tags") == 0) {
 	const char **tags;
 	size_t i, length;
-- 
2.7.4


Thread: