unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v3 00/10] "notmuch address" command
@ 2014-11-05  0:25 Michal Sojka
  2014-11-05  0:25 ` [PATCH v3 01/10] cli: search: Rename options to context Michal Sojka
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Michal Sojka @ 2014-11-05  0:25 UTC (permalink / raw)
  To: notmuch

Hi all,

this is v3 of "notmuch address" patchset. It obsoletes [1].

I think I addressed all comments made to v2. The diff between v2 and
v3 is below. Besides this, I improved commit messages.

I also tried to get rid of global variables in 6/10, but it looked
ugly, because the definition of keywords (e.g. "text", "json", ...)
had to be outside of option definition. So I kept the code as it was
in v2.

It seems that the agreement is to merge patches 1-9 for 0.19 and leave
patch 10 for further discussion.

Thanks
-Michal

[1] id:1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz


Jani Nikula (1):
  cli: add support for hierarchical command line option arrays

Michal Sojka (9):
  cli: search: Rename options to context
  cli: search: Move more variables into search_context_t
  cli: search: Convert ctx. to ctx->
  cli: search: Split notmuch_search_command to smaller functions
  cli: Introduce "notmuch address" command
  cli: search: Convert --output to keyword argument
  cli: address: Do not output duplicate addresses
  cli: address: Add --output=count
  cli: address: Add --filter-by option to configure address filtering

 command-line-arguments.c           |  16 +-
 command-line-arguments.h           |   1 +
 completion/notmuch-completion.bash |  48 +++-
 completion/notmuch-completion.zsh  |  11 +-
 doc/man1/notmuch-address.rst       | 132 +++++++++++
 doc/man1/notmuch-search.rst        |  21 +-
 doc/man1/notmuch.rst               |   7 +-
 notmuch-client.h                   |   3 +
 notmuch-search.c                   | 461 ++++++++++++++++++++++++++-----------
 notmuch.c                          |   2 +
 test/T095-address.sh               | 148 ++++++++++++
 test/T097-address-filter-by.sh     |  73 ++++++
 12 files changed, 750 insertions(+), 173 deletions(-)
 create mode 100644 doc/man1/notmuch-address.rst
 create mode 100755 test/T095-address.sh
 create mode 100755 test/T097-address-filter-by.sh

-- 
2.1.1

diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst
index 524ab91..00582c3 100644
--- a/doc/man1/notmuch-address.rst
+++ b/doc/man1/notmuch-address.rst
@@ -30,7 +30,7 @@ Supported options for **address** include
         intended for programs that invoke **notmuch(1)** internally. If
         omitted, the latest supported version will be used.
 
-    ``--output=(sender|recipients)``
+    ``--output=(sender|recipients|count)``
 
         Controls which information appears in the output. This option
 	can be given multiple times to combine different outputs.
@@ -64,7 +64,9 @@ Supported options for **address** include
         By default, results will be displayed in reverse chronological
         order, (that is, the newest results will be displayed first).
 
-    ``--exclude=(true|false|all|flag)``
+	This option has no effect when used with --output=count.
+
+    ``--exclude=(true|false)``
         A message is called "excluded" if it matches at least one tag in
         search.tag\_exclude that does not appear explicitly in the
         search terms. This option specifies whether to omit excluded
@@ -73,18 +75,8 @@ Supported options for **address** include
         The default value, **true**, prevents excluded messages from
         matching the search terms.
 
-        **all** additionally prevents excluded messages from appearing
-        in displayed results, in effect behaving as though the excluded
-        messages do not exist.
-
         **false** allows excluded messages to match search terms and
-        appear in displayed results. Excluded messages are still marked
-        in the relevant outputs.
-
-        **flag** only has an effect when ``--output=summary``. The
-        output is almost identical to **false**, but the "match count"
-        is the number of matching non-excluded messages in the thread,
-        rather than the number of matching messages.
+        appear in displayed results.
 
     ``--filter-by=``\ (**nameaddr**\ \|\ **name** \|\ **addr**\ \|\ **addrfold**\ \|\ **nameaddrfold**\)
 
diff --git a/notmuch-search.c b/notmuch-search.c
index 04e33c6..246ec0a 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -252,7 +252,9 @@ do_search_threads (search_context_t *ctx)
     return 0;
 }
 
-/* Returns TRUE iff name and/or addr is considered duplicate. */
+/* Returns TRUE iff name and/or addr is considered duplicate. If not,
+ * stores the name/addr pair in order to detect subsequent
+ * duplicates. */
 static notmuch_bool_t
 is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
 {
@@ -405,8 +407,9 @@ process_address_header (const search_context_t *ctx, const char *value)
     g_object_unref (list);
 }
 
+/* Destructor for talloc-allocated GHashTable keys and values. */
 static void
-_my_talloc_free_for_g_hash (void *ptr)
+_talloc_free_for_g_hash (void *ptr)
 {
     talloc_free (ptr);
 }
@@ -679,12 +682,6 @@ static const notmuch_opt_desc_t common_options[] = {
 			      { "text0", NOTMUCH_FORMAT_TEXT0 },
 			      { 0, 0 } } },
     { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },
-    { NOTMUCH_OPT_KEYWORD, &search_context.exclude, "exclude", 'x',
-      (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
-			      { "false", NOTMUCH_EXCLUDE_FALSE },
-			      { "flag", NOTMUCH_EXCLUDE_FLAG },
-			      { "all", NOTMUCH_EXCLUDE_ALL },
-			      { 0, 0 } } },
     { 0, 0, 0, 0, 0 }
 };
 
@@ -702,6 +699,12 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
 				  { "files", OUTPUT_FILES },
 				  { "tags", OUTPUT_TAGS },
 				  { 0, 0 } } },
+        { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
+          (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
+                                  { "false", NOTMUCH_EXCLUDE_FALSE },
+                                  { "flag", NOTMUCH_EXCLUDE_FLAG },
+                                  { "all", NOTMUCH_EXCLUDE_ALL },
+                                  { 0, 0 } } },
 	{ NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },
 	{ NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0  },
 	{ NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0  },
@@ -757,6 +760,10 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
 				  { "recipients", OUTPUT_RECIPIENTS },
 				  { "count", OUTPUT_COUNT },
 				  { 0, 0 } } },
+	{ NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
+	  (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
+				  { "false", NOTMUCH_EXCLUDE_FALSE },
+				  { 0, 0 } } },
 	{ NOTMUCH_OPT_KEYWORD, &ctx->filter_by, "filter-by", 'b',
 	  (notmuch_keyword_t []){ { "nameaddr", FILTER_BY_NAMEADDR },
 				  { "name", FILTER_BY_NAME },
@@ -774,14 +781,14 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
 	return EXIT_FAILURE;
 
     if (! ctx->output)
-	search_context.output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;
+	ctx->output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;
 
     if (_notmuch_search_prepare (ctx, config,
 				 argc - opt_index, argv + opt_index))
 	return EXIT_FAILURE;
 
     ctx->addresses = g_hash_table_new_full (g_str_hash, g_str_equal,
-					    _my_talloc_free_for_g_hash, _my_talloc_free_for_g_hash);
+					    _talloc_free_for_g_hash, _talloc_free_for_g_hash);
 
     ret = do_search_messages (ctx);
 
diff --git a/test/T095-address.sh b/test/T095-address.sh
index 92e17b0..033d0f4 100755
--- a/test/T095-address.sh
+++ b/test/T095-address.sh
@@ -91,8 +91,8 @@ Mikhail Gusarov <dottedmag@dottedmag.net>
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
-test_begin_subtest "No --output"
-notmuch address --output=sender --output=recipients '*' >OUTPUT
+test_begin_subtest "without --output"
+notmuch address '*' >OUTPUT
 # Use EXPECTED from previous subtest
 test_expect_equal_file OUTPUT EXPECTED
 

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

end of thread, other threads:[~2015-10-24  0:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05  0:25 [PATCH v3 00/10] "notmuch address" command Michal Sojka
2014-11-05  0:25 ` [PATCH v3 01/10] cli: search: Rename options to context Michal Sojka
2014-11-05  0:25 ` [PATCH v3 02/10] cli: search: Move more variables into search_context_t Michal Sojka
2014-11-05  0:25 ` [PATCH v3 03/10] cli: search: Convert ctx. to ctx-> Michal Sojka
2014-11-05  0:25 ` [PATCH v3 04/10] cli: search: Split notmuch_search_command to smaller functions Michal Sojka
2014-11-05  0:25 ` [PATCH v3 05/10] cli: add support for hierarchical command line option arrays Michal Sojka
2014-11-05  0:25 ` [PATCH v3 06/10] cli: Introduce "notmuch address" command Michal Sojka
2014-11-05 20:49   ` Tomi Ollila
2014-11-05  0:25 ` [PATCH v3 07/10] cli: search: Convert --output to keyword argument Michal Sojka
2014-11-05  0:25 ` [PATCH v3 08/10] cli: address: Do not output duplicate addresses Michal Sojka
2014-11-05  0:25 ` [PATCH v3 09/10] cli: address: Add --output=count Michal Sojka
2014-11-05 20:57   ` Tomi Ollila
2014-11-05 23:00   ` David Bremner
2014-11-05  0:25 ` [PATCH v3 10/10] cli: address: Add --filter-by option to configure address filtering Michal Sojka
2014-12-31 21:03   ` David Bremner
2015-01-01 12:03     ` Tomi Ollila
2015-01-09 13:22       ` Michal Sojka
2015-01-09 14:13         ` Tomi Ollila
2015-01-09 15:29           ` Michal Sojka
2015-01-09 16:31             ` Michal Sojka
2015-10-24  0:55   ` David Bremner

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