[notmuch] [PATCH 5/5] notmuch-new: Option to disable tags from the configuration...
authorJan Janak <jan@ryngle.com>
Wed, 25 Nov 2009 23:30:16 +0000 (00:30 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:43 +0000 (09:35 -0800)
0a/81592e5d46897b5832fde32126ab5bcdd8c4a0 [new file with mode: 0644]

diff --git a/0a/81592e5d46897b5832fde32126ab5bcdd8c4a0 b/0a/81592e5d46897b5832fde32126ab5bcdd8c4a0
new file mode 100644 (file)
index 0000000..ab8cde6
--- /dev/null
@@ -0,0 +1,171 @@
+Return-Path: <jan@ryngle.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id E11D7431FD4\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:30 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id FcdjqZYWrGpl for <notmuch@notmuchmail.org>;\r
+       Wed, 25 Nov 2009 15:30:29 -0800 (PST)\r
+Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com\r
+       [209.85.219.213])\r
+       by olra.theworths.org (Postfix) with ESMTP id 45566431FC4\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:27 -0800 (PST)\r
+Received: by mail-ew0-f213.google.com with SMTP id 5so257217ewy.30\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:27 -0800 (PST)\r
+Received: by 10.213.15.14 with SMTP id i14mr8585312eba.50.1259191826806;\r
+       Wed, 25 Nov 2009 15:30:26 -0800 (PST)\r
+Received: from x61s.janakj ([213.192.30.141])\r
+       by mx.google.com with ESMTPS id 28sm334056eyg.36.2009.11.25.15.30.23\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Wed, 25 Nov 2009 15:30:25 -0800 (PST)\r
+Received: by x61s.janakj (Postfix, from userid 1000)\r
+       id B525144065A; Thu, 26 Nov 2009 00:30:16 +0100 (CET)\r
+From: Jan Janak <jan@ryngle.com>\r
+To: notmuch@notmuchmail.org\r
+Date: Thu, 26 Nov 2009 00:30:16 +0100\r
+Message-Id: <1259191816-1982-5-git-send-email-jan@ryngle.com>\r
+X-Mailer: git-send-email 1.6.3.3\r
+In-Reply-To: <1259191816-1982-4-git-send-email-jan@ryngle.com>\r
+References: <1259100630-13673-1-git-send-email-jan@ryngle.com>\r
+       <1259191816-1982-1-git-send-email-jan@ryngle.com>\r
+       <1259191816-1982-2-git-send-email-jan@ryngle.com>\r
+       <1259191816-1982-3-git-send-email-jan@ryngle.com>\r
+       <1259191816-1982-4-git-send-email-jan@ryngle.com>\r
+Subject: [notmuch] [PATCH 5/5] notmuch-new: Option to disable tags from the\r
+       configuration file.\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 25 Nov 2009 23:30:31 -0000\r
+\r
+This patch slightly changes behavior of the command line option --tag.\r
+Any tags specified by the user on the command line will be added\r
+*in addition* to tags configured in the configuration file.\r
+\r
+This behavior can be changed with the new command line option\r
+--no-config-tags. The user can use this option to ignore any tags from\r
+the configuration file (i.e. only tags specified on the command line\r
+will be applied).\r
+\r
+With this new option the user can configure 'notmuch new' not to apply\r
+any tags (and that was not possible before):\r
+\r
+  notmuch new --no-config-tags\r
+\r
+Suggested by Karl Wiberg.\r
+\r
+Bugfix: Fix parsing of --verbose cmdline option.\r
+\r
+This is a revised version of the patch, incorporating suggestions made\r
+by Bart Trojanowski. Thanks Bart!\r
+\r
+Signed-off-by: Jan Janak <jan@ryngle.com>\r
+---\r
+ notmuch-new.c |   21 ++++++++++++---------\r
+ notmuch.c     |   13 +++++++++++--\r
+ 2 files changed, 23 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index cfbc6aa..eaed701 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -28,6 +28,7 @@ static notmuch_config_t *config = NULL;\r
\r
+ static char **cmdline_tags = NULL;\r
+ static size_t cmdline_tags_count = 0;\r
++static int add_config_tags = 1;\r
\r
+ static void\r
+ handle_sigalrm (unused (int signal))\r
+@@ -79,19 +80,19 @@ apply_tags (notmuch_message_t *message)\r
+     char** tags;\r
+     size_t count, i;\r
\r
++    if (add_config_tags) {\r
++      tags = notmuch_config_get_new_tags (config, &count);\r
++      for (i = 0; tags && (i < count); i++) {\r
++          if (tags[i])\r
++              notmuch_message_add_tag (message, tags[i]);\r
++      }\r
++    }\r
++\r
+     if (cmdline_tags_count) {\r
+       for (i = 0; i < cmdline_tags_count; i++) {\r
+           if (cmdline_tags[i])\r
+               notmuch_message_add_tag (message, cmdline_tags[i]);\r
+       }\r
+-    } else {\r
+-      if ((tags = notmuch_config_get_new_tags (config, &count)) == NULL)\r
+-          return;\r
+-\r
+-      for (i = 0; i < count; i++) {\r
+-          if (tags[i])\r
+-              notmuch_message_add_tag (message, tags[i]);\r
+-      }\r
+     }\r
+ }\r
\r
+@@ -432,7 +433,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+     add_files_state.output_is_a_tty = isatty (fileno (stdout));\r
\r
+     for (i = 0; i < argc && argv[i][0] == '-'; i++) {\r
+-      if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) {\r
++      if (strcmp (argv[i], "--verbose") == 0) {\r
+           add_files_state.verbose = 1;\r
+       } else if (STRNCMP_LITERAL (argv[i], "--tag=") == 0) {\r
+           opt = argv[i] + sizeof ("--tag=") - 1;\r
+@@ -451,6 +452,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+           }\r
+           tmp[cmdline_tags_count++] = opt;\r
+           cmdline_tags = tmp;\r
++      } else if (strcmp (argv[i], "--no-config-tags") == 0) {\r
++          add_config_tags = 0;\r
+       } else {\r
+           fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
+           return 1;\r
+diff --git a/notmuch.c b/notmuch.c\r
+index 1bd3265..2bb38f3 100644\r
+--- a/notmuch.c\r
++++ b/notmuch.c\r
+@@ -123,7 +123,7 @@ command_t commands[] = {\r
+       "\t\tInvoking notmuch with no command argument will run setup if\n"\r
+       "\t\tthe setup command has not previously been completed." },\r
+     { "new", notmuch_new_command,\r
+-      "[--verbose] [--tag=<name>]",\r
++      "[--verbose] [--tag=<name>] [--no-config-tags]",\r
+       "\t\tFind and import new messages to the notmuch database.",\r
+       "\t\tScans all sub-directories of the mail directory, performing\n"\r
+       "\t\tfull-text indexing on new messages that are found. Each new\n"\r
+@@ -149,7 +149,16 @@ command_t commands[] = {\r
+       "\n"\r
+       "\t\t\tAdd the tag <name> to all messages newly added to the\n"\r
+       "\t\t\tdatabase. You may repeat this option several times if\n"\r
+-      "\t\t\tyou want to add more tags.\n"\r
++      "\t\t\tyou want to add more tags. Any tags configured in the\n"\r
++      "\t\t\tconfiguration file will still be added, unless you also\n"\r
++      "\t\t\tuse the option --no-config-tags.\n"\r
++      "\n"\r
++      "\t\t--no-config-tags\n"\r
++      "\n"\r
++      "\t\t\tDo not add tags configured in the configuration file.\n"\r
++      "\t\t\tUse this option if you only want to add tags specified\n"\r
++      "\t\t\ton the command line with --tag or if do not want to add\n"\r
++      "\t\t\tany tags at all.\n"\r
+       "\n"\r
+       "\t\tNote: \"notmuch new\" runs (other than the first run) will\n"\r
+       "\t\tskip any read-only directories, so you can use that to mark\n"\r
+-- \r
+1.6.3.3\r
+\r