[PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / ba / 083e1a7c242640c1ea436bf23133cc59600967
1 Return-Path: <david@tethera.net>\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 olra.theworths.org (Postfix) with ESMTP id 10D9A431FAF\r
6         for <notmuch@notmuchmail.org>; Tue, 14 Jan 2014 05:22:25 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id v-ttB9gRtSrc for <notmuch@notmuchmail.org>;\r
16         Tue, 14 Jan 2014 05:22:17 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 2421B431FAE\r
21         for <notmuch@notmuchmail.org>; Tue, 14 Jan 2014 05:22:17 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <david@tethera.net>)\r
24         id 1W33wY-0006l2-6M; Tue, 14 Jan 2014 09:22:10 -0400\r
25 Received: (nullmailer pid 27441 invoked by uid 1000); Tue, 14 Jan 2014\r
26         13:22:06 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: Jani Nikula <jani@nikula.org>, Austin Clements <amdragon@MIT.EDU>\r
29 Subject: Re: [PATCH 2/2] lib: introduce notmuch_database_new for initializing\r
30         a database handle\r
31 In-Reply-To: <87mwkf40x5.fsf@nikula.org>\r
32 References: <cover.1385903109.git.jani@nikula.org>\r
33         <fc7ecd990e55fcfba17de4d71e8823c98760f9ce.1385903109.git.jani@nikula.org>\r
34         <20131204231113.GD8854@mit.edu> <87mwkf40x5.fsf@nikula.org>\r
35 User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1\r
36         (x86_64-pc-linux-gnu)\r
37 Date: Tue, 14 Jan 2014 09:22:06 -0400\r
38 Message-ID: <87a9eyk8ap.fsf@zancas.localnet>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain\r
41 Cc: notmuch@notmuchmail.org\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Tue, 14 Jan 2014 13:22:25 -0000\r
55 \r
56 Jani Nikula <jani@nikula.org> writes:\r
57 >> Austin Wrote:\r
58 >>\r
59 >> Orthogonally -- and this may be a complete pipe dream of mine -- if we\r
60 >> just had a way to return more detailed error information than a simple\r
61 >> error code from notmuch_database_{create,open}, I think we wouldn't\r
62 >> need any of this.  Everything that these functions currently log\r
63 >> (modulo one warning) is error details, so if we could return the error\r
64 >> details *with the error* or somehow make them accessible, we wouldn't\r
65 >> need a logger at this point (or at several other points in the\r
66 >> library).\r
67 >\r
68 > Agreed. I tried to look into this earlier, but was hitting dead ends\r
69 > *if* we want to keep reporting user friendly error status in\r
70 > open/create. Obviously any concrete suggestions would be most welcome!\r
71 >\r
72 \r
73 I'm not sure if this is also a dead end, but I was trying to sketch out\r
74 an api that returned something more detailed as status and came up with\r
75 the following.  The general idea is to replace notmuch_status_t with a\r
76 pointer to struct.  This will require pretty noisy source changes,\r
77 unless we're comfortable with using NULL pointer to indicate success.\r
78 In either case we'd rename the existing enum to something like\r
79 notmuch_status_code_t.\r
80 \r
81 /* pseudo-C follows */\r
82 \r
83 typedef struct notmuch_status_struct * notmuch_status_t;\r
84 \r
85 /* we can just tell external users to pass NULL as the first argument */\r
86 \r
87 notmuch_status_t notmuch_status_new (void *ctx, size_t bufsiz);\r
88 void notmuch_error_destroy (notuch_error_desc_t *victim);\r
89 \r
90 /* printf equivalent */\r
91 notmuch_status_t *notmuch_status_format(notmuch_status_t dest,\r
92                                         notmuch_status_code_t code,\r
93                                         const char *format, ...);\r
94 /* case 1, caller allocates */\r
95 status = notmuch_status_new (BUFSIZ);\r
96 if (!status) {\r
97     halt_and_catch_fire();\r
98 }\r
99 \r
100 /* open could continue to return notmuch_status_code_t, or just 0/1 */\r
101 if (notmuch_database_open (notmuch_config_get_database_path (config),\r
102                            NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch, status)) {\r
103     fprintf (stderr, "oops: %s\n", notmuch_status_to_string (status));\r
104     notmuch_error_destroy(error_details);\r
105     return 1;\r
106 }\r
107 \r
108 /* case 2, callee allocates */\r
109 \r
110 status = notmuch_message_freeze (message);\r
111 if (notmuch_status_to_code (status)) {  /* every check needs to be changed, unless NULL=OK */\r
112     message_error (message, status, "freezing message");\r
113     return status;\r
114 }\r
115 \r
116 /* some existing code is left alone */\r
117 \r
118 fprintf (stderr, "Message-ID: %s\n", notmuch_message_get_message_id (message));\r
119 fprintf (stderr, "Status: %s\n", notmuch_status_to_string (status));\r
120 \r