unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] cli: add support for parsing multiple keyword arguments
@ 2014-09-06 12:53 Jani Nikula
  2014-09-06 12:53 ` [PATCH 2/3] cli: add --output=address-{from, to, all} to notmuch search Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jani Nikula @ 2014-09-06 12:53 UTC (permalink / raw)
  To: notmuch

This allows having multiple --foo=bar --foo=baz options on the command
line, with the corresponding values OR'd together.
---
 command-line-arguments.c | 6 +++++-
 command-line-arguments.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/command-line-arguments.c b/command-line-arguments.c
index 844d6c3d18bf..c6f7269603cb 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;
 	}
@@ -152,6 +155,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);
 	case NOTMUCH_OPT_BOOLEAN:
 	    return _process_boolean_arg (try, next, value);
diff --git a/command-line-arguments.h b/command-line-arguments.h
index de1734ad2fdb..085a4923b5fa 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   */
 };
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH v1 0/3] Address completion entirely in elisp.
@ 2014-09-05 16:06 David Edmondson
  2014-09-06  8:14 ` [PATCH] cli: add --output=address-{from,to,all} to notmuch search Jani Nikula
  0 siblings, 1 reply; 11+ messages in thread
From: David Edmondson @ 2014-09-05 16:06 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Fri, Sep 05 2014, Mark Walters wrote:
> On Fri, 05 Sep 2014, David Edmondson <dme@dme.org> wrote:
>> Address completion entirely in elisp.
>>
>> I grew frustrated with having to use an external command to provide
>> address completion, as they all had annoyances (up front scanning,
>> requiring python bindings, etc.). This is an attempt to provide
>> something similar to jkr's notmuch-addresses.py (which I was
>> previously using) entirely in elisp, relying only on the `notmuch'
>> command.
>
> Just a few quick comments: the first is relevant to others trying this
> patch.
>
> 1) You seem to be missing a (require 'std11) somewhere. I did this via M-:
> and then it ran fine.

My apologies. Will fix (and a compiler warning at the same time).

> 2) It is not quick on a spinning rust disk. This may not be relevant as
> the delay is probably notmuch so would also be the case if I were using
> notmuch-addresses.py (i normally just use a trivial script that parses
> my .mailrc)

It's not always as fast as I would like on SSD either :-) The mechanism
is very similar to the equivalent Python program, so I think that it's
probably about the same.

> 3) Have you tried
> id:1407771091-12651-1-git-send-email-sojkam1@fel.cvut.cz and do you have
> any comments on the comparison?

No, I will dig it out and look.

> 4) Finally, I wonder if we would be worth approaching the backend
> notmuch use slightly differently: if we added a
> notmuch_messages_collect_from function which was very similar to
> notmuch_messages_collect_tags, and added a corresponding --output=from
> to notmuch search then you would get the information you need very
> quickly. I think it might be a lot faster as I think the from header is
> stored in the database but some other headers are not, so that the
> current method the show --body=false needs to look at the actually
> messages

Extending notmuch to help with this was next on my list of things to
do. At the moment I just needed a solution that worked.

> I should emphasise that none of the above means I am opposed to the
> patch: having respectable built in address-completion support would be
> very nice.

Cool, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-09-20  8:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-06 12:53 [PATCH 1/3] cli: add support for parsing multiple keyword arguments Jani Nikula
2014-09-06 12:53 ` [PATCH 2/3] cli: add --output=address-{from, to, all} to notmuch search Jani Nikula
2014-09-06 13:35   ` Mark Walters
2014-09-06 16:41     ` [PATCH] cli: add --output=address-{from,to,all} " Jani Nikula
2014-09-06 16:47       ` [PATCH] cli: add --output=address-{from, to, all} " Jani Nikula
2014-09-06 17:47       ` Mark Walters
2014-09-19 19:57       ` [PATCH] cli: add --output=address-{from,to,all} " David Bremner
2014-09-20  8:04         ` [PATCH] cli: add --output=address-{from, to, all} " Michal Sojka
2014-09-06 12:53 ` [PATCH 3/3] cli: deduplicate addresses for --output=address-* Jani Nikula
2014-09-19 19:27 ` [PATCH 1/3] cli: add support for parsing multiple keyword arguments David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2014-09-05 16:06 [PATCH v1 0/3] Address completion entirely in elisp David Edmondson
2014-09-06  8:14 ` [PATCH] cli: add --output=address-{from,to,all} to notmuch search Jani Nikula

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).