Re: [PATCH] cli: use designated initializers for opt desc

2017-10-01 Thread Jani Nikula
On Sun, 01 Oct 2017, Tomi Ollila wrote: > On Sun, Oct 01 2017, Jani Nikula wrote: > >> Several changes at once, just to not have to change the same lines >> several times over: >> >> - Use designated initializers to initialize opt desc arrays. >> >> - Only initialize the

Re: [PATCH 0/9] argument parsing fixes and improvements

2017-10-01 Thread Jani Nikula
On Sun, 01 Oct 2017, David Bremner wrote: > Jani Nikula writes: >> id:20170930213239.15392-1-j...@nikula.org would make it easier to add, >> say, a notmuch_bool_t *present field to notmuch_opt_desc_t that we could >> set whenever we see the option and we want

Re: notmuch-emacs: Fcc to top-level directory given by database.path

2017-10-01 Thread Arun Isaac
Mark Walters writes: > Incidentally, I think "/" is an alternative for the fcc line which > already works, which is "\"/\" in notmuch-fcc-dirs. Perhaps, notmuch should be made to tolerate a "/" at the beginning of the Fcc folder argument. That is, notmuch should not

[PATCH v2 01/15] cli: strip trailing "/" from the final maildir path in notmuch insert

2017-10-01 Thread Jani Nikula
Several subtle interconnected changes here: - If the folder name passed as argument is the empty string "" or slash "/", the final maildir path would end up having "//" in it. We should strip the final maildir path, not folder. - The folder variable should really be const char *, another

[PATCH v2 02/15] cli: use designated initializers for opt desc

2017-10-01 Thread Jani Nikula
Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output

[PATCH v2 08/15] hex-xcode: use notmuch_bool_t for boolean arguments

2017-10-01 Thread Jani Nikula
Pedantically correct, although they're the same underlying type. --- test/hex-xcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hex-xcode.c b/test/hex-xcode.c index bc2df713b2a3..221ccdb90843 100644 --- a/test/hex-xcode.c +++ b/test/hex-xcode.c @@ -45,7 +45,7 @@

[PATCH v2 05/15] cli: add .present field to opt desc to check if the arg was present

2017-10-01 Thread Jani Nikula
Add pointer to boolean .present field to opt desc, which (if non-NULL) will be set to TRUE if the argument in question is present on the command line. Unchanged otherwise. --- command-line-arguments.c | 11 --- command-line-arguments.h | 3 +++ 2 files changed, 11 insertions(+), 3

[PATCH v2 03/15] test: add boolean argument to arg-test

2017-10-01 Thread Jani Nikula
Surprisingly it's not there. --- test/T410-argument-parsing.sh | 3 ++- test/arg-test.c | 5 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh index fad134e305c5..4505c58301ea 100755 ---

[PATCH v2 00/15] cli: argument parsing changes

2017-10-01 Thread Jani Nikula
This series combines the designated initializers for argument parsing from id:20170930213239.15392-1-j...@nikula.org and the argument parsing refactoring from id:cover.1505853159.git.j...@nikula.org. Additionally patch 1 handles some const confusion in notmuch-insert before it becomes a problem

[PATCH v2 06/15] test: expand argument parsing tests

2017-10-01 Thread Jani Nikula
Test and use the new .present field, only output the parameters given. Test space between parameter name and value. --- test/T410-argument-parsing.sh | 22 ++ test/arg-test.c | 33 ++--- 2 files changed, 40 insertions(+), 15

[PATCH v2 12/15] cli: reduce indent in keyword argument processing

2017-10-01 Thread Jani Nikula
Reducing indent makes future changes easier. No functional changes. --- command-line-arguments.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index c591dcbec7cc..3fa8d9044966 100644 ---

Re: [PATCH] cli: use designated initializers for opt desc

2017-10-01 Thread Tomi Ollila
On Sun, Oct 01 2017, Jani Nikula wrote: > Several changes at once, just to not have to change the same lines > several times over: > > - Use designated initializers to initialize opt desc arrays. > > - Only initialize the needed fields. > > - Remove arg_id (short options) as unused. > > - Replace

Re: [PATCH] cli: use designated initializers for opt desc

2017-10-01 Thread Tomi Ollila
On Sun, Oct 01 2017, Jani Nikula wrote: > On Sun, 01 Oct 2017, Tomi Ollila wrote: >> >> Good stuff. It just doesn't longer compile on older compilers (so some >> note on commit message should be added): > > Does this on top fix it? I used the unnamed struct just for clarity,

[PATCH v2 07/15] cli: use the arg parser .present feature to handle show --entire-thread

2017-10-01 Thread Jani Nikula
The --entire-thread default depends on other arguments, so we'll have to figure out if it was explicitly set by the user or not. The arg parser .present feature helps us clean up the code here. --- notmuch-show.c | 19 ++- 1 file changed, 6 insertions(+), 13 deletions(-) diff

[PATCH v2 10/15] cli: refactor boolean argument processing

2017-10-01 Thread Jani Nikula
Clean up the control flow to prepare for future changes. No functional changes. --- command-line-arguments.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index 39940d5fb9fd..ee8be18942d0

[PATCH v2 15/15] test: expand argument parsing sanity checks

2017-10-01 Thread Jani Nikula
Test the various boolean formats and --no- prefixed boolean and keyword flag arguments. --- test/T410-argument-parsing.sh | 28 1 file changed, 28 insertions(+) diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh index

[PATCH v2 14/15] cli: use the negating boolean support for new and insert --no-hooks

2017-10-01 Thread Jani Nikula
This lets us use the positive hooks variable in code, increasing clarity. --- notmuch-insert.c | 6 +++--- notmuch-new.c| 8 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index bbbc29ea103d..7048e8ae2d7f 100644 ---

[PATCH v2 09/15] cli: use notmuch_bool_t for boolean argument in show

2017-10-01 Thread Jani Nikula
Pedantically correct, although they're the same underlying type. --- notmuch-show.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notmuch-show.c b/notmuch-show.c index d0e86f412e80..3d11a40c6a59 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1085,7 +1085,7 @@

[PATCH v2 11/15] cli: change while to for in keyword argument processing

2017-10-01 Thread Jani Nikula
Using a for loop makes it easier to use continue, in preparation for future changes. No functional changes. --- command-line-arguments.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index ee8be18942d0..c591dcbec7cc

[PATCH v2 13/15] cli: add support for --no- prefixed boolean and keyword flag arguments

2017-10-01 Thread Jani Nikula
Add transparent support for negating boolean and keyword flag arguments using --no-argument style on the command line. That is, if the option description contains a boolean or a keyword flag argument named "argument", --no-argument will match and negate it. For boolean arguments this obviously

Re: [PATCH 5/6] cli/new: support // in new.ignore

2017-10-01 Thread David Bremner
Jani Nikula writes: >> >> One thing we eventually settled on in the query parser is that an >> opening '/' without a trailing '/' is an errror. But perhaps it's fine >> to take a more permissive approach here. > > I'm fine either way, I just chose to be permissive. > > So do I

Re: [PATCH v2 12/15] cli: reduce indent in keyword argument processing

2017-10-01 Thread David Bremner
Jani Nikula writes: > Reducing indent makes future changes easier. No functional changes. First 12 patches LGTM. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch

Re: [PATCH 6/6] test: test regexp based new.ignore

2017-10-01 Thread David Bremner
Jani Nikula writes: > Just some basics. > --- > test/T050-new.sh | 22 ++ > 1 file changed, 22 insertions(+) Tests fail after applying this patch (output attached). It sortof looks like the regexp ignore is not working? T50.out Description: Binary data

Re: [PATCH v2 13/15] cli: add support for --no- prefixed boolean and keyword flag arguments

2017-10-01 Thread William Casarin
Jani Nikula writes: > @@ -171,11 +186,22 @@ parse_option (int argc, char **argv, const > notmuch_opt_desc_t *options, int opt_ > if (! try->name) > continue; > > - if (strncmp (arg, try->name, strlen (try->name)) != 0) > + char next; > + const char

[PATCH v2 04/15] test: add opt_inherit to arg-test

2017-10-01 Thread Jani Nikula
Just split the arguments to two opt desc arrays. --- test/arg-test.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/arg-test.c b/test/arg-test.c index 9d13618bd17c..a379f23e308a 100644 --- a/test/arg-test.c +++ b/test/arg-test.c @@ -14,18 +14,23 @@ int

Re: [PATCH] cli: use designated initializers for opt desc

2017-10-01 Thread Jani Nikula
On Sun, 01 Oct 2017, Tomi Ollila wrote: > On Sun, Oct 01 2017, Jani Nikula wrote: > >> On Sun, 01 Oct 2017, Tomi Ollila wrote: >>> >>> Good stuff. It just doesn't longer compile on older compilers (so some >>> note on commit message should be added): >> >>

Re: [PATCH] cli: use designated initializers for opt desc

2017-10-01 Thread David Bremner
Jani Nikula writes: > Several changes at once, just to not have to change the same lines > several times over: the general approach here looks fine. I didn't see any blockers, but I'll wait a few days before merging. This probably causes some rebasing pain for other people,

Re: [PATCH 0/9] argument parsing fixes and improvements

2017-10-01 Thread David Bremner
Jani Nikula writes: > On Sat, 30 Sep 2017, Jani Nikula wrote: >> Looking at the defaults from another angle, if we don't want the ability >> to set --foo=default explicitly, I still think passing ints as booleans >> to the argument parser and checking if a