Re: Regarding notmuch and Fedora 16
[notmuch-archives.git] / e3 / 3114dea19c5a8e292ee98dca013c2b04ad5cec
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 AD1E9431FBC\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 10:37:37 -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 2LHICxHI3y1d for <notmuch@notmuchmail.org>;\r
11         Wed, 25 Nov 2009 10:37:36 -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 90736431FAE\r
15         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 10:37:36 -0800 (PST)\r
16 Received: by ewy5 with SMTP id 5so4680994ewy.30\r
17         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 10:37:35 -0800 (PST)\r
18 Received: by 10.213.100.167 with SMTP id y39mr2111626ebn.59.1259174254914;\r
19         Wed, 25 Nov 2009 10:37:34 -0800 (PST)\r
20 Received: from x61s.janakj ([213.192.30.141])\r
21         by mx.google.com with ESMTPS id 24sm68883eyx.22.2009.11.25.10.37.33\r
22         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
23         Wed, 25 Nov 2009 10:37:34 -0800 (PST)\r
24 Received: by x61s.janakj (Postfix, from userid 1000)\r
25         id 52B1D440655; Wed, 25 Nov 2009 19:37:31 +0100 (CET)\r
26 From: Jan Janak <jan@ryngle.com>\r
27 To: notmuch@notmuchmail.org\r
28 Date: Wed, 25 Nov 2009 19:37:31 +0100\r
29 Message-Id: <1259174251-27298-1-git-send-email-jan@ryngle.com>\r
30 X-Mailer: git-send-email 1.6.3.3\r
31 In-Reply-To: <1259100630-13673-5-git-send-email-jan@ryngle.com>\r
32 References: <1259100630-13673-5-git-send-email-jan@ryngle.com>\r
33 Subject: [notmuch] [PATCH] notmuch-new: Option to disable tags from the\r
34         configuration file.\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.12\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Wed, 25 Nov 2009 18:37:37 -0000\r
48 \r
49 This patch slightly changes behavior of the command line option --tag.\r
50 Any tags specified by the user on the command line will be added\r
51 *in addition* to tags configured in the configuration file.\r
52 \r
53 This behavior can be changed with the new command line option\r
54 --no-config-tags. The user can use this option to ignore any tags from\r
55 the configuration file (i.e. only tags specified on the command line\r
56 will be applied).\r
57 \r
58 With this new option the user can configure 'notmuch new' not to apply\r
59 any tags (and that was not possible before):\r
60 \r
61   notmuch new --no-config-tags\r
62 \r
63 Suggested by Karl Wiberg.\r
64 \r
65 Signed-off-by: Jan Janak <jan@ryngle.com>\r
66 ---\r
67  notmuch-new.c |   19 +++++++++++--------\r
68  notmuch.c     |   11 ++++++++++-\r
69  2 files changed, 21 insertions(+), 9 deletions(-)\r
70 \r
71 diff --git a/notmuch-new.c b/notmuch-new.c\r
72 index 94036da..e988bf1 100644\r
73 --- a/notmuch-new.c\r
74 +++ b/notmuch-new.c\r
75 @@ -28,6 +28,7 @@ static notmuch_config_t *config = NULL;\r
76  \r
77  static char **cmdline_tags = NULL;\r
78  static unsigned int cmdline_tags_count = 0;\r
79 +static int add_config_tags = 1;\r
80  \r
81  static void\r
82  handle_sigalrm (unused (int signal))\r
83 @@ -79,19 +80,19 @@ apply_tags (notmuch_message_t *message)\r
84      char** tags;\r
85      unsigned int count, i;\r
86  \r
87 +    if (add_config_tags) {\r
88 +       tags = notmuch_config_get_new_tags (config, &count);\r
89 +       for (i = 0; tags && (i < count); i++) {\r
90 +           if (tags[i])\r
91 +               notmuch_message_add_tag (message, tags[i]);\r
92 +       }\r
93 +    }\r
94 +\r
95      if (cmdline_tags_count) {\r
96         for (i = 0; i < cmdline_tags_count; i++) {\r
97             if (cmdline_tags[i])\r
98                 notmuch_message_add_tag (message, cmdline_tags[i]);\r
99         }\r
100 -    } else {\r
101 -       if ((tags = notmuch_config_get_new_tags (config, &count)) == NULL)\r
102 -           return;\r
103 -\r
104 -       for (i = 0; i < count; i++) {\r
105 -           if (tags[i])\r
106 -               notmuch_message_add_tag (message, tags[i]);\r
107 -       }\r
108      }\r
109  }\r
110  \r
111 @@ -451,6 +452,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
112             }\r
113             tmp[cmdline_tags_count++] = opt;\r
114             cmdline_tags = tmp;\r
115 +       } else if (STRNCMP_LITERAL (argv[i], "--no-config-tags") == 0) {\r
116 +           add_config_tags = 0;\r
117         } else {\r
118             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
119             return 1;\r
120 diff --git a/notmuch.c b/notmuch.c\r
121 index 1bd3265..ff8d5bb 100644\r
122 --- a/notmuch.c\r
123 +++ b/notmuch.c\r
124 @@ -149,7 +149,16 @@ command_t commands[] = {\r
125        "\n"\r
126        "\t\t\tAdd the tag <name> to all messages newly added to the\n"\r
127        "\t\t\tdatabase. You may repeat this option several times if\n"\r
128 -      "\t\t\tyou want to add more tags.\n"\r
129 +      "\t\t\tyou want to add more tags. Any tags configured in the\n"\r
130 +      "\t\t\tconfiguration file will still be added, unless you also\n"\r
131 +      "\t\t\tuse the option --no-config-tags.\n"\r
132 +      "\n"\r
133 +      "\t\t--no-config-tags\n"\r
134 +      "\n"\r
135 +      "\t\t\tDo not add tags configured in the configuration file.\n"\r
136 +      "\t\t\tUse this option if you only want to add tags specified\n"\r
137 +      "\t\t\ton the command line with --tag or if do not want to add\n"\r
138 +      "\t\t\tany tags at all.\n"\r
139        "\n"\r
140        "\t\tNote: \"notmuch new\" runs (other than the first run) will\n"\r
141        "\t\tskip any read-only directories, so you can use that to mark\n"\r
142 -- \r
143 1.6.3.3\r
144 \r