unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: david@tethera.net, notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: Re: [Patch v6 1/6] tag-util: factor out rules for illegal tags, use in parse_tag_line
Date: Thu, 13 Dec 2012 22:07:32 +0000	[thread overview]
Message-ID: <871uettxln.fsf@qmul.ac.uk> (raw)
In-Reply-To: <1355096008-4544-2-git-send-email-david@tethera.net>


I don't know if this matters but it seems that one can still add a "-"
tag by doing something like

echo "+%2d -- search" | notmuch tag --batch

This might be the right thing to do but I thought I would mention it.

Best wishes

Mark

On Sun, 09 Dec 2012, david@tethera.net wrote:
> From: David Bremner <bremner@debian.org>
>
> This will allow us to be consistent between batch tagging and command
> line tagging as far as what is an illegal tag.
> ---
>  tag-util.c |   35 ++++++++++++++++++++++++++++++-----
>  1 file changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/tag-util.c b/tag-util.c
> index eab482f..c071ea8 100644
> --- a/tag-util.c
> +++ b/tag-util.c
> @@ -31,6 +31,29 @@ line_error (tag_parse_status_t status,
>      return status;
>  }
>  
> +/*
> + * Test tags for some forbidden cases.
> + *
> + * return: NULL if OK,
> + *	   explanatory message otherwise.
> + */
> +
> +static const char *
> +illegal_tag (const char *tag, notmuch_bool_t remove) {
> +
> +    if (*tag == '\0' && !remove)
> +	return "adding empty tag";
> +
> +    /* This disallows adding the non-removable tag "-" and
> +     * enables notmuch tag to take long options more easily.
> +     */
> +
> +    if (*tag == '-' && !remove)
> +	return  "adding tag starting with -";
> +
> +    return NULL;
> +}
> +
>  tag_parse_status_t
>  parse_tag_line (void *ctx, char *line,
>  		tag_op_flag_t flags,
> @@ -95,11 +118,13 @@ parse_tag_line (void *ctx, char *line,
>  	remove = (*tok == '-');
>  	tag = tok + 1;
>  
> -	/* Maybe refuse empty tags. */
> -	if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') {
> -	    ret = line_error (TAG_PARSE_INVALID, line_for_error,
> -			      "empty tag");
> -	    goto DONE;
> +	/* Maybe refuse illegal tags. */
> +	if (! (flags & TAG_FLAG_BE_GENEROUS)) {
> +	    const char *msg = illegal_tag (tag, remove);
> +	    if (msg) {
> +		ret = line_error (TAG_PARSE_INVALID, line_for_error, msg);
> +		goto DONE;
> +	    }
>  	}
>  
>  	/* Decode tag. */
> -- 
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  parent reply	other threads:[~2012-12-13 22:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-09 23:33 V6 batch tagging patches david
2012-12-09 23:33 ` [Patch v6 1/6] tag-util: factor out rules for illegal tags, use in parse_tag_line david
2012-12-10 20:55   ` Jani Nikula
2012-12-13 22:07   ` Mark Walters [this message]
2012-12-15 12:39     ` David Bremner
2012-12-09 23:33 ` [Patch v6 2/6] notmuch-tag.c: convert to use tag-utils david
2012-12-10 21:18   ` Jani Nikula
2012-12-10 21:51   ` Jani Nikula
2012-12-09 23:33 ` [Patch v6 3/6] cli: add support for batch tagging operations to "notmuch tag" david
2012-12-10 21:29   ` Jani Nikula
2012-12-09 23:33 ` [Patch v6 4/6] test: add test for notmuch tag --batch option david
2012-12-10 21:31   ` Jani Nikula
2012-12-09 23:33 ` [Patch v6 5/6] notmuch-tag.1: tidy synopsis formatting david
2012-12-10 21:32   ` Jani Nikula
2012-12-09 23:33 ` [Patch v6 6/6] man: document notmuch tag --batch, --input options david
2012-12-10 21:34   ` Jani Nikula
2012-12-10  0:59 ` V6 batch tagging patches David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871uettxln.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=bremner@debian.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).