[PATCH 1/4] Add user.other_name property to associate names with other_email.
[notmuch-archives.git] / 3a / 8f2b11efaa425ac397a712b612f87950a34ef2
1 Return-Path: <shea@shealevy.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 2A2F96DE0281\r
6  for <notmuch@notmuchmail.org>; Tue,  9 Aug 2016 14:04:12 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.02\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.02 tagged_above=-999 required=5\r
12  tests=[RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01,\r
13  RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id iBpt6P5qqAmg for <notmuch@notmuchmail.org>;\r
17  Tue,  9 Aug 2016 14:04:03 -0700 (PDT)\r
18 X-Greylist: delayed 445 seconds by postgrey-1.35 at arlo;\r
19  Tue, 09 Aug 2016 14:04:03 PDT\r
20 Received: from smtprelay.hostedemail.com (smtprelay0165.hostedemail.com\r
21  [216.40.44.165])\r
22  by arlo.cworth.org (Postfix) with ESMTPS id 989306DE01C2\r
23  for <notmuch@notmuchmail.org>; Tue,  9 Aug 2016 14:04:03 -0700 (PDT)\r
24 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com\r
25  [10.5.19.251])\r
26  by smtpgrave08.hostedemail.com (Postfix) with ESMTP id F160921172D\r
27  for <notmuch@notmuchmail.org>; Tue,  9 Aug 2016 20:56:40 +0000 (UTC)\r
28 Received: from filter.hostedemail.com (unknown [216.40.38.60])\r
29  by smtprelay07.hostedemail.com (Postfix) with ESMTP id A1809C1F81\r
30  for <notmuch@notmuchmail.org>; Tue,  9 Aug 2016 20:56:39 +0000 (UTC)\r
31 X-Session-Marker: 7368656140736865616C6576792E636F6D\r
32 X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, shea@shealevy.com, :,\r
33  RULES_HIT:41:355:379:541:960:973:988:989:1252:1260:1345:1359:1381:1437:1534:1543:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:3872:3873:3874:4321:4552:5007:6261:7903:9010:9163:10004:10044:10848:11026:11658:11914:12043:12291:12296:12438:12517:12519:12555:12683:14110:14181:14394:14721:21080:21433:30003:30022:30030:30051:30054, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none,\r
34  DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0,\r
35  LFtime:1, LUA_SUMMARY:none\r
36 X-HE-Tag: toys92_1cd2613433624\r
37 X-Filterd-Recvd-Size: 4524\r
38 Received: from shlevy-laptop.local.tld (unknown [184.209.6.164])\r
39  (Authenticated sender: shea@shealevy.com)\r
40  by omf08.hostedemail.com (Postfix) with ESMTPA\r
41  for <notmuch@notmuchmail.org>; Tue,  9 Aug 2016 20:56:37 +0000 (UTC)\r
42 From: Shea Levy <shea@shealevy.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 1/4] Add user.other_name property to associate names with\r
45  other_email.\r
46 Date: Tue,  9 Aug 2016 16:55:15 -0400\r
47 Message-Id: <1470776118-5070-2-git-send-email-shea@shealevy.com>\r
48 X-Mailer: git-send-email 2.7.4\r
49 In-Reply-To: <1470776118-5070-1-git-send-email-shea@shealevy.com>\r
50 References: <1470776118-5070-1-git-send-email-shea@shealevy.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.20\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55  <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
57  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
62  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Tue, 09 Aug 2016 21:04:12 -0000\r
64 \r
65 Entries are paired with the email address at the same index in\r
66 other_email. To use user.name for a given other_email, leave that\r
67 entry blank or leave user.other_name shorter than the relevant index\r
68 altogether.\r
69 ---\r
70  notmuch-client.h |  9 +++++++++\r
71  notmuch-config.c | 32 ++++++++++++++++++++++++++++++++\r
72  2 files changed, 41 insertions(+)\r
73 \r
74 diff --git a/notmuch-client.h b/notmuch-client.h\r
75 index ebc092b..69c83a2 100644\r
76 --- a/notmuch-client.h\r
77 +++ b/notmuch-client.h\r
78 @@ -304,6 +304,15 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,\r
79                                      size_t length);\r
80  \r
81  const char **\r
82 +notmuch_config_get_user_other_name (notmuch_config_t *config,\r
83 +                                   size_t *length);\r
84 +\r
85 +void\r
86 +notmuch_config_set_user_other_name (notmuch_config_t *config,\r
87 +                                   const char *other_name[],\r
88 +                                   size_t length);\r
89 +\r
90 +const char **\r
91  notmuch_config_get_new_tags (notmuch_config_t *config,\r
92                              size_t *length);\r
93  void\r
94 diff --git a/notmuch-config.c b/notmuch-config.c\r
95 index e5d42a0..4ac16b7 100644\r
96 --- a/notmuch-config.c\r
97 +++ b/notmuch-config.c\r
98 @@ -63,6 +63,8 @@ static const char user_config_comment[] =\r
99      "\tprimary_email   Your primary email address.\n"\r
100      "\tother_email     A list (separated by ';') of other email addresses\n"\r
101      "\t                at which you receive email.\n"\r
102 +    "\tother_name      A list (separated by ';') of names corresponding to\n"\r
103 +    "\t        other_email addresses. Leave an entry blank to use default\n"\r
104      "\n"\r
105      " Notmuch will use the various email addresses configured here when\n"\r
106      " formatting replies. It will avoid including your own addresses in the\n"\r
107 @@ -120,6 +122,8 @@ struct _notmuch_config {\r
108      char *user_primary_email;\r
109      const char **user_other_email;\r
110      size_t user_other_email_length;\r
111 +    const char **user_other_name;\r
112 +    size_t user_other_name_length;\r
113      const char **new_tags;\r
114      size_t new_tags_length;\r
115      const char **new_ignore;\r
116 @@ -237,6 +241,8 @@ get_username_from_passwd_file (void *ctx)\r
117   *\r
118   *             user_other_email:       Not set.\r
119   *\r
120 + *             user_other_name:        Not set.\r
121 + *\r
122   *     The default configuration also contains comments to guide the\r
123   *     user in editing the file directly.\r
124   */\r
125 @@ -280,6 +286,8 @@ notmuch_config_open (void *ctx,\r
126      config->user_primary_email = NULL;\r
127      config->user_other_email = NULL;\r
128      config->user_other_email_length = 0;\r
129 +    config->user_other_name = NULL;\r
130 +    config->user_other_name_length = 0;\r
131      config->new_tags = NULL;\r
132      config->new_tags_length = 0;\r
133      config->new_ignore = NULL;\r
134 @@ -674,6 +682,23 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,\r
135                      &(config->user_other_email));\r
136  }\r
137  \r
138 +const char **\r
139 +notmuch_config_get_user_other_name (notmuch_config_t *config, size_t *length)\r
140 +{\r
141 +    return _config_get_list (config, "user", "other_name",\r
142 +                            &(config->user_other_name),\r
143 +                            &(config->user_other_name_length), length);\r
144 +}\r
145 +\r
146 +void\r
147 +notmuch_config_set_user_other_name (notmuch_config_t *config,\r
148 +                                   const char *list[],\r
149 +                                   size_t length)\r
150 +{\r
151 +    _config_set_list (config, "user", "other_name", list, length,\r
152 +                    &(config->user_other_name));\r
153 +}\r
154 +\r
155  void\r
156  notmuch_config_set_new_tags (notmuch_config_t *config,\r
157                                      const char *list[],\r
158 @@ -790,6 +815,13 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)\r
159         other_email = notmuch_config_get_user_other_email (config, &length);\r
160         for (i = 0; i < length; i++)\r
161             printf ("%s\n", other_email[i]);\r
162 +    } else if (strcmp(item, "user.other_name") == 0) {\r
163 +       const char **other_name;\r
164 +       size_t i, length;\r
165 +\r
166 +       other_name = notmuch_config_get_user_other_name (config, &length);\r
167 +       for (i = 0; i < length; i++)\r
168 +           printf ("%s\n", other_name[i]);\r
169      } else if (strcmp(item, "new.tags") == 0) {\r
170         const char **tags;\r
171         size_t i, length;\r
172 -- \r
173 2.7.4\r
174 \r