Re: Flat search and threaded views
[notmuch-archives.git] / 7e / f3373b7c48b7bf94527a01cb5657990536cae0
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 7F6F76DE1AFA\r
6  for <notmuch@notmuchmail.org>; Mon,  6 Apr 2015 05:24:11 -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.474\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.474 tagged_above=-999 required=5 tests=[AWL=0.464, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id jL268kYEiiJn for <notmuch@notmuchmail.org>;\r
16  Mon,  6 Apr 2015 05:24:09 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id B10F56DE1AEA\r
20  for <notmuch@notmuchmail.org>; Mon,  6 Apr 2015 05:24:09 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1Yf63r-00058v-SP; Mon, 06 Apr 2015 12:23:27 +0000\r
24 Received: (nullmailer pid 3286 invoked by uid 1000); Mon, 06 Apr 2015\r
25  12:22:58 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
28 Subject: [Patch v2 4/4] cli: add standard option processing to config and\r
29  setup\r
30 Date: Mon,  6 Apr 2015 21:22:38 +0900\r
31 Message-Id: <1428322958-2887-5-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 2.1.4\r
33 In-Reply-To: <1428322958-2887-1-git-send-email-david@tethera.net>\r
34 References: <87d23ixnr7.fsf@maritornes.cs.unb.ca>\r
35  <1428322958-2887-1-git-send-email-david@tethera.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.18\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40  <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Mon, 06 Apr 2015 12:24:11 -0000\r
49 \r
50 In particular this fixes a recently encountered bug where the\r
51 "--config" argument to "notmuch setup" is silently ignored, which the\r
52 unpleasant consequence of overwriting the users config file.\r
53 ---\r
54  notmuch-config.c     | 16 +++++++++++++++-\r
55  notmuch-setup.c      | 12 ++++++++++++\r
56  test/random-corpus.c |  9 +++++++++\r
57  3 files changed, 36 insertions(+), 1 deletion(-)\r
58 \r
59 diff --git a/notmuch-config.c b/notmuch-config.c\r
60 index 2d5c297..f2cd6a8 100644\r
61 --- a/notmuch-config.c\r
62 +++ b/notmuch-config.c\r
63 @@ -872,8 +872,22 @@ int\r
64  notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])\r
65  {\r
66      int ret;\r
67 +    int opt_index;\r
68  \r
69 -    argc--; argv++; /* skip subcommand argument */\r
70 +    notmuch_opt_desc_t options[] = {\r
71 +       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
72 +       { 0, 0, 0, 0, 0 }\r
73 +    };\r
74 +\r
75 +    opt_index = parse_arguments (argc, argv, options, 1);\r
76 +    if (opt_index < 0)\r
77 +       return EXIT_FAILURE;\r
78 +\r
79 +    notmuch_process_shared_options (argv[0]);\r
80 +\r
81 +    /* skip at least subcommand argument */\r
82 +    argc-= opt_index;\r
83 +    argv+= opt_index;\r
84  \r
85      if (argc < 1) {\r
86         fprintf (stderr, "Error: notmuch config requires at least one argument.\n");\r
87 diff --git a/notmuch-setup.c b/notmuch-setup.c\r
88 index 36a6171..6a020dc 100644\r
89 --- a/notmuch-setup.c\r
90 +++ b/notmuch-setup.c\r
91 @@ -133,6 +133,7 @@ notmuch_setup_command (notmuch_config_t *config,\r
92      size_t new_tags_len;\r
93      const char **search_exclude_tags;\r
94      size_t search_exclude_tags_len;\r
95 +    int opt_index;\r
96  \r
97  #define prompt(format, ...)                                    \\r
98      do {                                                       \\r
99 @@ -145,6 +146,17 @@ notmuch_setup_command (notmuch_config_t *config,\r
100         chomp_newline (response);                               \\r
101      } while (0)\r
102  \r
103 +    notmuch_opt_desc_t options[] = {\r
104 +       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
105 +       { 0, 0, 0, 0, 0 }\r
106 +    };\r
107 +\r
108 +    opt_index = parse_arguments (argc, argv, options, 1);\r
109 +    if (opt_index < 0)\r
110 +       return EXIT_FAILURE;\r
111 +\r
112 +    notmuch_process_shared_options ("setup");\r
113 +\r
114      if (notmuch_config_is_new (config))\r
115         welcome_message_pre_setup ();\r
116  \r
117 diff --git a/test/random-corpus.c b/test/random-corpus.c\r
118 index 790193d..6c467bb 100644\r
119 --- a/test/random-corpus.c\r
120 +++ b/test/random-corpus.c\r
121 @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count)\r
122      return buf;\r
123  }\r
124  \r
125 +/* stubs since we cannot link with notmuch.o */\r
126 +const notmuch_opt_desc_t notmuch_shared_options[] = {\r
127 +       { 0, 0, 0, 0, 0 }\r
128 +};\r
129 +\r
130 +void\r
131 +notmuch_process_shared_options (unused (const char *dummy))\r
132 +{\r
133 +}\r
134  \r
135  int\r
136  main (int argc, char **argv)\r
137 -- \r
138 2.1.4\r
139 \r