1 Return-Path: <tomi.ollila@nixu.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 olra.theworths.org (Postfix) with ESMTP id 5D089431FD0
\r
6 for <notmuch@notmuchmail.org>; Sat, 10 Sep 2011 02:15:54 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 Eh3rsZRPTCwB for <notmuch@notmuchmail.org>;
\r
16 Sat, 10 Sep 2011 02:15:52 -0700 (PDT)
\r
17 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id D45E6431FB6
\r
21 for <notmuch@notmuchmail.org>; Sat, 10 Sep 2011 02:15:39 -0700 (PDT)
\r
22 Received: from taco2.nixu.fi (localhost [127.0.0.1])
\r
23 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
25 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
\r
26 for <notmuch@notmuchmail.org>; Sat, 10 Sep 2011 12:15:37 +0300
\r
27 Received: (from too@localhost)
\r
28 by taco2.nixu.fi (8.14.3/8.14.3/Submit) id p8A9FaLw023438;
\r
29 Sat, 10 Sep 2011 12:15:36 +0300
\r
30 X-Authentication-Warning: taco2.nixu.fi: too set sender to
\r
31 tomi.ollila@nixu.com using -f
\r
32 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
33 To: <notmuch@notmuchmail.org>
\r
34 Subject: suggestion: notmuch-talloc.[ch]
\r
35 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
36 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
37 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
38 Date: Sat, 10 Sep 2011 12:15:36 +0300
\r
39 Message-ID: <yf6sjo4rc5j.fsf@taco2.nixu.fi>
\r
40 User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/22.2 (gnu/linux)
\r
42 Content-Type: text/plain
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Sat, 10 Sep 2011 09:15:54 -0000
\r
58 In addition to notmuch_config_get_new_tags() I started to think
\r
59 how to add notmuch_config_get_database_exclude() (for excluding
\r
60 directories; needed by me and many others)
\r
62 to copy and modify from notmuch_config_get_new_tags() would cause
\r
63 lots of duplicate code so I started to look how to generalise.
\r
65 Not so simple so I started to look "bigger picture" and this leads
\r
68 new c file called 'notmuch-talloc.c', with the following initial
\r
71 --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
\r
73 # include <add required includes...>
\r
76 notmuch_talloc_g_string_list_destructor (void * ptr)
\r
78 g_strfreev ( (gchar **)ptr );
\r
81 /* tallocify wrapper for g_key_file_get_string_list */
\r
84 void notmuch_talloc_g_key_file_get_string_list (const void * ctx,
\r
86 const gchar *group_name,
\r
91 gchar ** tags = g_key_file_get_string_list (key_file,
\r
95 talloc_reference(ctx, tags);
\r
96 talloc_set_destructor(tags, notmuch_talloc_g_string_list_destructor);
\r
101 --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
\r
103 Provided that the above is proven correct, this would simplify
\r
104 notmuch_config_get_new_tags() as:
\r
107 notmuch_config_get_new_tags (notmuch_config_t *config,
\r
110 if (config->new_tags == NULL) {
\r
111 config->new_tags = notmuch_talloc_g_key_file_get_string_list(
\r
115 &config->tags_length, NULL);
\r
118 return config->new_tags;
\r
121 Thus adding notmuch_config_get_database_exclude() avoids the
\r
122 CopyPasteProgramming threshold.
\r
124 new code to the notmuch-talloc.c (and interface declarations to
\r
125 notmuch-talloc.h) would be added on demand, per need basis.
\r
127 Note that this code is unproven code. For obvious reason i'm currently
\r
128 hesitant to investigate further -- all of us have priorities -- but
\r
129 if this idea gets good response I'm willing to do the proper patches;
\r
130 for now, for my own use, I just hardcode excluded directories to
\r