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 AD1E9431FBC for ; Wed, 25 Nov 2009 10:37:37 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 2LHICxHI3y1d for ; Wed, 25 Nov 2009 10:37:36 -0800 (PST) Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com [209.85.219.213]) by olra.theworths.org (Postfix) with ESMTP id 90736431FAE for ; Wed, 25 Nov 2009 10:37:36 -0800 (PST) Received: by ewy5 with SMTP id 5so4680994ewy.30 for ; Wed, 25 Nov 2009 10:37:35 -0800 (PST) Received: by 10.213.100.167 with SMTP id y39mr2111626ebn.59.1259174254914; Wed, 25 Nov 2009 10:37:34 -0800 (PST) Received: from x61s.janakj ([213.192.30.141]) by mx.google.com with ESMTPS id 24sm68883eyx.22.2009.11.25.10.37.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 25 Nov 2009 10:37:34 -0800 (PST) Received: by x61s.janakj (Postfix, from userid 1000) id 52B1D440655; Wed, 25 Nov 2009 19:37:31 +0100 (CET) From: Jan Janak To: notmuch@notmuchmail.org Date: Wed, 25 Nov 2009 19:37:31 +0100 Message-Id: <1259174251-27298-1-git-send-email-jan@ryngle.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1259100630-13673-5-git-send-email-jan@ryngle.com> References: <1259100630-13673-5-git-send-email-jan@ryngle.com> Subject: [notmuch] [PATCH] notmuch-new: Option to disable tags from the configuration file. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Wed, 25 Nov 2009 18:37:37 -0000 This patch slightly changes behavior of the command line option --tag. Any tags specified by the user on the command line will be added *in addition* to tags configured in the configuration file. This behavior can be changed with the new command line option --no-config-tags. The user can use this option to ignore any tags from the configuration file (i.e. only tags specified on the command line will be applied). With this new option the user can configure 'notmuch new' not to apply any tags (and that was not possible before): notmuch new --no-config-tags Suggested by Karl Wiberg. Signed-off-by: Jan Janak --- notmuch-new.c | 19 +++++++++++-------- notmuch.c | 11 ++++++++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 94036da..e988bf1 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -28,6 +28,7 @@ static notmuch_config_t *config = NULL; static char **cmdline_tags = NULL; static unsigned int cmdline_tags_count = 0; +static int add_config_tags = 1; static void handle_sigalrm (unused (int signal)) @@ -79,19 +80,19 @@ apply_tags (notmuch_message_t *message) char** tags; unsigned int count, i; + if (add_config_tags) { + tags = notmuch_config_get_new_tags (config, &count); + for (i = 0; tags && (i < count); i++) { + if (tags[i]) + notmuch_message_add_tag (message, tags[i]); + } + } + if (cmdline_tags_count) { for (i = 0; i < cmdline_tags_count; i++) { if (cmdline_tags[i]) notmuch_message_add_tag (message, cmdline_tags[i]); } - } else { - if ((tags = notmuch_config_get_new_tags (config, &count)) == NULL) - return; - - for (i = 0; i < count; i++) { - if (tags[i]) - notmuch_message_add_tag (message, tags[i]); - } } } @@ -451,6 +452,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) } tmp[cmdline_tags_count++] = opt; cmdline_tags = tmp; + } else if (STRNCMP_LITERAL (argv[i], "--no-config-tags") == 0) { + add_config_tags = 0; } else { fprintf (stderr, "Unrecognized option: %s\n", argv[i]); return 1; diff --git a/notmuch.c b/notmuch.c index 1bd3265..ff8d5bb 100644 --- a/notmuch.c +++ b/notmuch.c @@ -149,7 +149,16 @@ command_t commands[] = { "\n" "\t\t\tAdd the tag to all messages newly added to the\n" "\t\t\tdatabase. You may repeat this option several times if\n" - "\t\t\tyou want to add more tags.\n" + "\t\t\tyou want to add more tags. Any tags configured in the\n" + "\t\t\tconfiguration file will still be added, unless you also\n" + "\t\t\tuse the option --no-config-tags.\n" + "\n" + "\t\t--no-config-tags\n" + "\n" + "\t\t\tDo not add tags configured in the configuration file.\n" + "\t\t\tUse this option if you only want to add tags specified\n" + "\t\t\ton the command line with --tag or if do not want to add\n" + "\t\t\tany tags at all.\n" "\n" "\t\tNote: \"notmuch new\" runs (other than the first run) will\n" "\t\tskip any read-only directories, so you can use that to mark\n" -- 1.6.3.3