unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: Jani Nikula <jani@nikula.org>, John Lenz <lenz@math.uic.edu>,
	notmuch@notmuchmail.org
Subject: Re: cli: add --include-html option to notmuch show
Date: Sun, 18 Aug 2013 21:30:56 +0300	[thread overview]
Message-ID: <m2wqni7swv.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <87k3jjutpf.fsf@nikula.org>

On Sun, Aug 18 2013, Jani Nikula <jani@nikula.org> wrote:

> On Sat, 17 Aug 2013, John Lenz <lenz@math.uic.edu> wrote:
>> On Sun Aug  4 14:47 -0500 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
>>> The next question is should we have new option as
>>> 
>>> --include-html
>>> 
>>> or as
>>> 
>>> --include-html=(true|false)
>>> 
>>> or even
>>> 
>>> --body=(true|false|text-and-html)
>>> 
>>> See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/
>>> and --body option in http://notmuchmail.org/manpages/notmuch-show-1/
>>> for comparison...
>>> 
>>
>> I have no preference here, although I guess I would vote for
>> --include-html=(true|false) since adding it to --body makes the --body
>> options confusing: to make sense the body options should be
>> --body=(text|text-and-html|none) but of course you can't change that and
>> break the command line API.  Well, maybe you could add all three
>> --body=(text|text-and-html|none)  and still accept true/false for
>> compatibility.
>
> Hi John & Tomi -
>
> We could trivially amend the argument parser to |= the keyword values
> (instead of =) to allow specifying keywords arguments multiple times on
> the command line. With the keyword values specified as bit flags, we
> could then have 'notmuch show --body=text --body=html ...' return both
> text and html, and allow trivial future extension too.
>
> --body=true and --body=false could be handled specially for backwards
> compatibility, for example by forcing text only or no parts,
> respectively. Since the default is currently text, --body=none might be
> a suitable synonym for --body=false, while the boolean alternatives
> could be deprecated.
>
> A little less trivially it's also possible to support e.g. comma
> separated keyword values, such as --body=text,html but I do prefer the
> (implementation) simplicity of the above.

I've also thought along these lines (except this possibility to give 
argument multiple times)...

But when I wrote my first reply I did not realise that the default
behaviour is to include all text/* parts *except* text/html. i.e.
text/html is excluded as as special case (and non-excluded parts
contain text/plain, text/calendar, text/whatnot etc...). 

How to do clean interface/implementation using --body is not trivial
(if possible). I played with options like
false/none -- true/text/plain -- all/textall/* and came to a conclusion
that maybe --include-html is the best option after all.

Now, if we have --include-html should it be like that or 
--include-html=(true|false). Currently we have both cases, adding
--verify, --decrypt, --create-folder, --batch, -no-hooks to the
set... I cannot get a clear opinion (without wast^H^H^H^H spending
excessive amount of time figuring these out) how this should be,
therefore I'm inclined to the opinion that

the current patch from John with simple --include-html could be applied,
and in the future (if it is of anyone's interest) we update the parser
allowing boolean --arg equal --arg=true. Then it is just how we decide
to document these...

Tomi

>
> Untested patch to the argument parser below.
>
> Cheers,
> Jani.
>
>
> diff --git a/command-line-arguments.c b/command-line-arguments.c
> index bf9aeca..c426054 100644
> --- a/command-line-arguments.c
> +++ b/command-line-arguments.c
> @@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
>      while (keywords->name) {
>  	if (strcmp (arg_str, keywords->name) == 0) {
>  	    if (arg_desc->output_var) {
> -		*((int *)arg_desc->output_var) = keywords->value;
> +		if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)
> +		    *((int *)arg_desc->output_var) |= keywords->value;
> +		else
> +		    *((int *)arg_desc->output_var) = keywords->value;
>  	    }
>  	    return TRUE;
>  	}
> @@ -146,6 +149,7 @@ parse_option (const char *arg,
>  
>  	    switch (try->opt_type) {
>  	    case NOTMUCH_OPT_KEYWORD:
> +	    case NOTMUCH_OPT_KEYWORD_FLAGS:
>  		return _process_keyword_arg (try, next, value);
>  		break;
>  	    case NOTMUCH_OPT_BOOLEAN:
> diff --git a/command-line-arguments.h b/command-line-arguments.h
> index de1734a..085a492 100644
> --- a/command-line-arguments.h
> +++ b/command-line-arguments.h
> @@ -8,6 +8,7 @@ enum notmuch_opt_type {
>      NOTMUCH_OPT_BOOLEAN,	/* --verbose              */
>      NOTMUCH_OPT_INT,		/* --frob=8               */
>      NOTMUCH_OPT_KEYWORD,	/* --format=raw|json|text */
> +    NOTMUCH_OPT_KEYWORD_FLAGS,  /* the above with values OR'd together */
>      NOTMUCH_OPT_STRING,		/* --file=/tmp/gnarf.txt  */
>      NOTMUCH_OPT_POSITION	/* notmuch dump pos_arg   */
>  };
>
>
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2013-08-18 18:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02  0:19 cli: add --include-html option to notmuch show John Lenz
2013-07-21 20:23 ` Tomi Ollila
2013-07-22 16:49   ` John Lenz
2013-07-25  2:36   ` John Lenz
2013-08-04 19:47     ` Tomi Ollila
2013-08-17 15:52       ` John Lenz
2013-08-18 11:25         ` Jani Nikula
2013-08-18 18:30           ` Tomi Ollila [this message]
2013-08-24  8:11             ` Mark Walters
2013-08-24 10:59             ` Jani Nikula
2013-08-24 15:29 ` [PATCH 1/1] test: test notmuch show --include-html option Tomi Ollila
2013-08-24 21:36   ` Mark Walters
2013-08-27 11:04   ` David Bremner
2013-08-27 11:03 ` cli: add --include-html option to notmuch show 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=m2wqni7swv.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=jani@nikula.org \
    --cc=lenz@math.uic.edu \
    --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).