Re: [PATCH v4 16/16] add "notmuch reindex" subcommand
[notmuch-archives.git] / 0a / 81592e5d46897b5832fde32126ab5bcdd8c4a0
1 Return-Path: <jan@ryngle.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 E11D7431FD4\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:30 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id FcdjqZYWrGpl for <notmuch@notmuchmail.org>;\r
11         Wed, 25 Nov 2009 15:30:29 -0800 (PST)\r
12 Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com\r
13         [209.85.219.213])\r
14         by olra.theworths.org (Postfix) with ESMTP id 45566431FC4\r
15         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:27 -0800 (PST)\r
16 Received: by mail-ew0-f213.google.com with SMTP id 5so257217ewy.30\r
17         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:27 -0800 (PST)\r
18 Received: by 10.213.15.14 with SMTP id i14mr8585312eba.50.1259191826806;\r
19         Wed, 25 Nov 2009 15:30:26 -0800 (PST)\r
20 Received: from x61s.janakj ([213.192.30.141])\r
21         by mx.google.com with ESMTPS id 28sm334056eyg.36.2009.11.25.15.30.23\r
22         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
23         Wed, 25 Nov 2009 15:30:25 -0800 (PST)\r
24 Received: by x61s.janakj (Postfix, from userid 1000)\r
25         id B525144065A; Thu, 26 Nov 2009 00:30:16 +0100 (CET)\r
26 From: Jan Janak <jan@ryngle.com>\r
27 To: notmuch@notmuchmail.org\r
28 Date: Thu, 26 Nov 2009 00:30:16 +0100\r
29 Message-Id: <1259191816-1982-5-git-send-email-jan@ryngle.com>\r
30 X-Mailer: git-send-email 1.6.3.3\r
31 In-Reply-To: <1259191816-1982-4-git-send-email-jan@ryngle.com>\r
32 References: <1259100630-13673-1-git-send-email-jan@ryngle.com>\r
33         <1259191816-1982-1-git-send-email-jan@ryngle.com>\r
34         <1259191816-1982-2-git-send-email-jan@ryngle.com>\r
35         <1259191816-1982-3-git-send-email-jan@ryngle.com>\r
36         <1259191816-1982-4-git-send-email-jan@ryngle.com>\r
37 Subject: [notmuch] [PATCH 5/5] notmuch-new: Option to disable tags from the\r
38         configuration file.\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.12\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Wed, 25 Nov 2009 23:30:31 -0000\r
52 \r
53 This patch slightly changes behavior of the command line option --tag.\r
54 Any tags specified by the user on the command line will be added\r
55 *in addition* to tags configured in the configuration file.\r
56 \r
57 This behavior can be changed with the new command line option\r
58 --no-config-tags. The user can use this option to ignore any tags from\r
59 the configuration file (i.e. only tags specified on the command line\r
60 will be applied).\r
61 \r
62 With this new option the user can configure 'notmuch new' not to apply\r
63 any tags (and that was not possible before):\r
64 \r
65   notmuch new --no-config-tags\r
66 \r
67 Suggested by Karl Wiberg.\r
68 \r
69 Bugfix: Fix parsing of --verbose cmdline option.\r
70 \r
71 This is a revised version of the patch, incorporating suggestions made\r
72 by Bart Trojanowski. Thanks Bart!\r
73 \r
74 Signed-off-by: Jan Janak <jan@ryngle.com>\r
75 ---\r
76  notmuch-new.c |   21 ++++++++++++---------\r
77  notmuch.c     |   13 +++++++++++--\r
78  2 files changed, 23 insertions(+), 11 deletions(-)\r
79 \r
80 diff --git a/notmuch-new.c b/notmuch-new.c\r
81 index cfbc6aa..eaed701 100644\r
82 --- a/notmuch-new.c\r
83 +++ b/notmuch-new.c\r
84 @@ -28,6 +28,7 @@ static notmuch_config_t *config = NULL;\r
85  \r
86  static char **cmdline_tags = NULL;\r
87  static size_t cmdline_tags_count = 0;\r
88 +static int add_config_tags = 1;\r
89  \r
90  static void\r
91  handle_sigalrm (unused (int signal))\r
92 @@ -79,19 +80,19 @@ apply_tags (notmuch_message_t *message)\r
93      char** tags;\r
94      size_t count, i;\r
95  \r
96 +    if (add_config_tags) {\r
97 +       tags = notmuch_config_get_new_tags (config, &count);\r
98 +       for (i = 0; tags && (i < count); i++) {\r
99 +           if (tags[i])\r
100 +               notmuch_message_add_tag (message, tags[i]);\r
101 +       }\r
102 +    }\r
103 +\r
104      if (cmdline_tags_count) {\r
105         for (i = 0; i < cmdline_tags_count; i++) {\r
106             if (cmdline_tags[i])\r
107                 notmuch_message_add_tag (message, cmdline_tags[i]);\r
108         }\r
109 -    } else {\r
110 -       if ((tags = notmuch_config_get_new_tags (config, &count)) == NULL)\r
111 -           return;\r
112 -\r
113 -       for (i = 0; i < count; i++) {\r
114 -           if (tags[i])\r
115 -               notmuch_message_add_tag (message, tags[i]);\r
116 -       }\r
117      }\r
118  }\r
119  \r
120 @@ -432,7 +433,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
121      add_files_state.output_is_a_tty = isatty (fileno (stdout));\r
122  \r
123      for (i = 0; i < argc && argv[i][0] == '-'; i++) {\r
124 -       if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) {\r
125 +       if (strcmp (argv[i], "--verbose") == 0) {\r
126             add_files_state.verbose = 1;\r
127         } else if (STRNCMP_LITERAL (argv[i], "--tag=") == 0) {\r
128             opt = argv[i] + sizeof ("--tag=") - 1;\r
129 @@ -451,6 +452,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
130             }\r
131             tmp[cmdline_tags_count++] = opt;\r
132             cmdline_tags = tmp;\r
133 +       } else if (strcmp (argv[i], "--no-config-tags") == 0) {\r
134 +           add_config_tags = 0;\r
135         } else {\r
136             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
137             return 1;\r
138 diff --git a/notmuch.c b/notmuch.c\r
139 index 1bd3265..2bb38f3 100644\r
140 --- a/notmuch.c\r
141 +++ b/notmuch.c\r
142 @@ -123,7 +123,7 @@ command_t commands[] = {\r
143        "\t\tInvoking notmuch with no command argument will run setup if\n"\r
144        "\t\tthe setup command has not previously been completed." },\r
145      { "new", notmuch_new_command,\r
146 -      "[--verbose] [--tag=<name>]",\r
147 +      "[--verbose] [--tag=<name>] [--no-config-tags]",\r
148        "\t\tFind and import new messages to the notmuch database.",\r
149        "\t\tScans all sub-directories of the mail directory, performing\n"\r
150        "\t\tfull-text indexing on new messages that are found. Each new\n"\r
151 @@ -149,7 +149,16 @@ command_t commands[] = {\r
152        "\n"\r
153        "\t\t\tAdd the tag <name> to all messages newly added to the\n"\r
154        "\t\t\tdatabase. You may repeat this option several times if\n"\r
155 -      "\t\t\tyou want to add more tags.\n"\r
156 +      "\t\t\tyou want to add more tags. Any tags configured in the\n"\r
157 +      "\t\t\tconfiguration file will still be added, unless you also\n"\r
158 +      "\t\t\tuse the option --no-config-tags.\n"\r
159 +      "\n"\r
160 +      "\t\t--no-config-tags\n"\r
161 +      "\n"\r
162 +      "\t\t\tDo not add tags configured in the configuration file.\n"\r
163 +      "\t\t\tUse this option if you only want to add tags specified\n"\r
164 +      "\t\t\ton the command line with --tag or if do not want to add\n"\r
165 +      "\t\t\tany tags at all.\n"\r
166        "\n"\r
167        "\t\tNote: \"notmuch new\" runs (other than the first run) will\n"\r
168        "\t\tskip any read-only directories, so you can use that to mark\n"\r
169 -- \r
170 1.6.3.3\r
171 \r