1 Return-Path: <jrollins@finestructure.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 92984431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 10 Apr 2012 00:22:11 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 zO5Msrzt36o3 for <notmuch@notmuchmail.org>;
\r
16 Tue, 10 Apr 2012 00:22:11 -0700 (PDT)
\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 0346F431FAE
\r
20 for <notmuch@notmuchmail.org>; Tue, 10 Apr 2012 00:22:10 -0700 (PDT)
\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])
\r
22 by fire-doxen-postvirus (Postfix) with ESMTP id 6A9EB2E50D7C;
\r
23 Tue, 10 Apr 2012 00:22:10 -0700 (PDT)
\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new
\r
25 Received: from finestructure.net (unknown [76.89.193.65])
\r
26 (Authenticated sender: jrollins)
\r
27 by fire-doxen-submit (Postfix) with ESMTP id 7EA282E50D42;
\r
28 Tue, 10 Apr 2012 00:22:07 -0700 (PDT)
\r
29 Received: by finestructure.net (Postfix, from userid 1000)
\r
30 id 1732D762; Tue, 10 Apr 2012 00:22:07 -0700 (PDT)
\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
32 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH v3 4/5] config: Add 'config list' command
\r
34 In-Reply-To: <1333676886-9835-5-git-send-email-novalazy@gmail.com>
\r
35 References: <1332282698-7951-1-git-send-email-novalazy@gmail.com>
\r
36 <1333676886-9835-1-git-send-email-novalazy@gmail.com>
\r
37 <1333676886-9835-5-git-send-email-novalazy@gmail.com>
\r
38 User-Agent: Notmuch/0.12+108~g7bdb40c (http://notmuchmail.org) Emacs/23.4.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Tue, 10 Apr 2012 00:22:01 -0700
\r
41 Message-ID: <87r4vwhx0m.fsf@servo.finestructure.net>
\r
43 Content-Type: multipart/signed; boundary="=-=-=";
\r
44 micalg=pgp-sha256; protocol="application/pgp-signature"
\r
45 X-BeenThere: notmuch@notmuchmail.org
\r
46 X-Mailman-Version: 2.1.13
\r
48 List-Id: "Use and development of the notmuch mail system."
\r
49 <notmuch.notmuchmail.org>
\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
53 List-Post: <mailto:notmuch@notmuchmail.org>
\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
57 X-List-Received-Date: Tue, 10 Apr 2012 07:22:11 -0000
\r
60 Content-Transfer-Encoding: quoted-printable
\r
62 On Thu, Apr 05 2012, Peter Wang <novalazy@gmail.com> wrote:
\r
63 > Add a command to list all configuration items with their associated
\r
66 > One use is as follows: a MUA may prefer to store data in a central
\r
67 > notmuch configuration file so that the data is accessible across
\r
68 > different machines, e.g. an addressbook. The list command helps
\r
69 > to implement features such as tab completion on the keys.
\r
71 > notmuch-config.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++=
\r
74 > 2 files changed, 62 insertions(+), 5 deletions(-)
\r
76 > diff --git a/notmuch-config.c b/notmuch-config.c
\r
77 > index 85fc774..d5540ac 100644
\r
78 > --- a/notmuch-config.c
\r
79 > +++ b/notmuch-config.c
\r
80 > @@ -799,20 +799,78 @@ notmuch_config_command_set (void *ctx, char *item, =
\r
81 int argc, char *argv[])
\r
86 > +notmuch_config_command_list (void *ctx)
\r
88 > + notmuch_config_t *config;
\r
90 > + size_t g, groups_length;
\r
92 > + config =3D notmuch_config_open (ctx, NULL, NULL);
\r
93 > + if (config =3D=3D NULL)
\r
96 > + groups =3D g_key_file_get_groups (config->key_file, &groups_length);
\r
97 > + if (groups =3D=3D NULL)
\r
100 > + for (g =3D 0; g < groups_length; g++) {
\r
102 > + size_t k, keys_length;
\r
104 > + keys =3D g_key_file_get_keys (config->key_file,
\r
105 > + groups[g], &keys_length, NULL);
\r
106 > + if (keys =3D=3D NULL)
\r
109 > + for (k =3D 0; k < keys_length; k++) {
\r
112 > + value =3D g_key_file_get_string (config->key_file,
\r
113 > + groups[g], keys[k], NULL);
\r
114 > + if (value !=3D NULL) {
\r
115 > + printf ("%s.%s=3D%s\n", groups[g], keys[k], value);
\r
120 > + g_strfreev (keys);
\r
123 > + g_strfreev (groups);
\r
125 > + notmuch_config_close (config);
\r
131 > notmuch_config_command (void *ctx, int argc, char *argv[])
\r
133 > argc--; argv++; /* skip subcommand argument */
\r
135 > - if (argc < 2) {
\r
136 > - fprintf (stderr, "Error: notmuch config requires at least two arguments=
\r
138 > + if (argc < 1) {
\r
139 > + fprintf (stderr, "Error: notmuch config requires at least one argument.=
\r
144 Hey, Peter. I would say everything up to here looks great.
\r
146 > - if (strcmp (argv[0], "get") =3D=3D 0)
\r
147 > + if (strcmp (argv[0], "get") =3D=3D 0) {
\r
148 > + if (argc < 2) {
\r
149 > + fprintf (stderr, "Error: notmuch config get requires at least "
\r
150 > + "two arguments.\n");
\r
153 > return notmuch_config_command_get (ctx, argv[1]);
\r
154 > - else if (strcmp (argv[0], "set") =3D=3D 0)
\r
155 > + } else if (strcmp (argv[0], "set") =3D=3D 0) {
\r
156 > + if (argc < 2) {
\r
157 > + fprintf (stderr, "Error: notmuch config set requires at least "
\r
158 > + "two arguments.\n");
\r
161 > return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);
\r
163 But then these changes look unrelated to me. They do look good
\r
164 intentioned, though. It's probably best to submit these changes in a
\r
165 separate unrelated patch.
\r
170 Content-Type: application/pgp-signature
\r
172 -----BEGIN PGP SIGNATURE-----
\r
173 Version: GnuPG v1.4.12 (GNU/Linux)
\r
175 iQIcBAEBCAAGBQJPg9+aAAoJEO00zqvie6q8svMQAIR79rchJLmp9H04JOjdn8pi
\r
176 GNMTmW3IXH9mTe4H86vvGbeSHZh2ERp3NR8nFDkjmLD7JMMPagvoGLXA8HLVwlDA
\r
177 3Fmar/lqIjvbknUjch5Ho/a6hykuzXScO09FPw5Y2B/vr6mWrhcaqUeZ/HHJ5eUc
\r
178 SFhFT3pN08J54cbOFEUmMEZ5MtVd+JgsweLaKf4rNyXcrYv/0x+8gZbh2kZqVMYn
\r
179 UAe4ZvvQTmKyDN60dCeutATkhE8BVu6wtDU5dOov11cho9lHj5Oz+VKeTNx2ahok
\r
180 Nsd5vOHim3uB08L7Y1i8KYfy+wU8a7UDQzoO0LdxkEKpooICLsX3Jk6eVtRUhdg1
\r
181 64EHzKd55vxMF7psJvw2hoacfVmMHUinMdPjutT0z4RiLhKL1PDyPEv3eA4GBfPN
\r
182 RkNBXYz9HcP/4LGHsVAQ08xmIeu9+hQpxR0qszJ4m89lBVoQoKMJtJ3ttq5V/mQo
\r
183 wPX5zGOCWCY4EDzBm0s+OArO88a1bUBbquegN7z0asoucS06Xd3cb4LhmM4TywDV
\r
184 Meh9k2p337IPpRB2p+qV9TWuud+f9597Z24cAyT+gn9JbKAoE5WVdyzzcBRPWaxU
\r
185 cmXGwsj8GDvkJ/93Q7S1TQXzPTRrXhY9IislBQUkAKAvoprok6Jc03ZSpSHuw2mC
\r
186 IfYXph/namcKZi+ETteA
\r
188 -----END PGP SIGNATURE-----
\r