Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 084C5431FC0 for ; Tue, 20 Mar 2012 15:34:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vNUzpR7aR9AA for ; Tue, 20 Mar 2012 15:34:21 -0700 (PDT) Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 81C49431FAE for ; Tue, 20 Mar 2012 15:34:21 -0700 (PDT) Received: by dady25 with SMTP id y25so706824dad.26 for ; Tue, 20 Mar 2012 15:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=ocv2j0ru7M3tdr3oaEIqKsmR2AMoEGP9+z2on4B6kHo=; b=FgM6c3lCHNApHFm0L8oXUf803cirwUIn6J3kJHnmMuJgaL4ZuxD75qlR4vb3su08SW +u6TK5VCXkWh3bBBVwcm3aIhoo8IhTCkfJ1LB2lskz+miRN0GuEma54Hm5GjVW6zEa49 oc5JRi7z0MiY53hUDTBc0qd5R9hv/Ki3O6bZ1MBR4yOlZbTeaS4MM+BVLMQHScnTkZ8K ZEgk5LsKnCIuTEelDLlp+wA+yjjb2TkdwhUS2LMzNhvnwsuM1eajj4z0Bu9Q/fN1Y36v 3o+w0cX7CllhdmlQg9vFdWfyp+9GACLZdqe/J1MB13EC6HfOk0jteDEwE6Q1vRrJLDeG lCoA== Received: by 10.68.233.168 with SMTP id tx8mr5134911pbc.72.1332282860328; Tue, 20 Mar 2012 15:34:20 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id f5sm2180693pbe.26.2012.03.20.15.34.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Mar 2012 15:34:19 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH 1/2] config: Add 'config list' command Date: Wed, 21 Mar 2012 09:31:37 +1100 Message-Id: <1332282698-7951-1-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.4.4 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Mar 2012 22:34:22 -0000 Add a command to list all keys in a given configuration section. One use is as follows: a MUA may prefer to store data in a central notmuch configuration file so that the data is accessible across different machines, e.g. an addressbook. The list command helps to implement features such as tab completion on the keys. --- notmuch-config.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index e9b2750..595cf54 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -799,6 +799,31 @@ notmuch_config_command_set (void *ctx, char *item, int argc, char *argv[]) return ret; } +static int +notmuch_config_command_list (void *ctx, char *group) +{ + notmuch_config_t *config; + char **keys; + size_t i, length; + + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; + + keys = g_key_file_get_keys (config->key_file, + group, &length, NULL); + if (keys != NULL) { + for (i = 0; i < length; i++) + printf ("%s\n", keys[i]); + + free (keys); + } + + notmuch_config_close (config); + + return 0; +} + int notmuch_config_command (void *ctx, int argc, char *argv[]) { @@ -813,6 +838,8 @@ notmuch_config_command (void *ctx, int argc, char *argv[]) return notmuch_config_command_get (ctx, argv[1]); else if (strcmp (argv[0], "set") == 0) return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2); + else if (strcmp (argv[0], "list") == 0) + return notmuch_config_command_list (ctx, argv[1]); fprintf (stderr, "Unrecognized argument for notmuch config: %s\n", argv[0]); -- 1.7.4.4