mu: default to include related, skip dups

Add optioins --include-dups and --skip-related that are the reverse of
the previous ones. Leave the old options (hidden) for backward
compat (ie., scripts that use those options)
This commit is contained in:
Dirk-Jan C. Binnema 2019-12-01 16:09:28 +02:00
parent 0bc2e605a4
commit f86ed12eb3
5 changed files with 35 additions and 24 deletions

View File

@ -42,7 +42,7 @@ The search pattern is taken as a command-line parameter. If the search
parameter consists of multiple parts (as in the example) they are parameter consists of multiple parts (as in the example) they are
treated as if there were a logical \fBand\fR between them. treated as if there were a logical \fBand\fR between them.
For details on the possible queries, see For details on the possible queries, see
@ -209,17 +209,17 @@ details of the bookmarks file.
.TP .TP
\fB\-\-skip\-dups\fR,\fB-u\fR whenever there are multiple messages with the \fB\-\-include\-dups\fR,\fB-u\fR by default, whenever there are multiple
same name, only show the first one. This is useful if you have copies of the messages with the same name, only show the first one. This is useful if you have
same message, which is a common occurrence when using e.g. Gmail together with copies of the same message, which is a common occurrence when using e.g. Gmail
\fBofflineimap\fR. together with \fBofflineimap\fR. Use this option to turn that behavior off.
.TP .TP
\fB\-\-include\-related\fR,\fB-r\fR also include messages being refered to by \fB\-\-skip\-related\fR,\fB-r\fR by default, the results include messages being
the matched messages -- i.e.. include messages that are part of the same refered to by the matched messages -- i.e.. include messages that are part of
message thread as some matched messages. This is useful if you want the same message thread as some matched messages. This is useful if you want
Gmail-style 'conversations'. Note, finding these related messages make Gmail-style 'conversations'. Note, finding these related messages make searches
searches slower. slightly slower. Use this option to turn that behavior off.
.TP .TP
\fB\-t\fR, \fB\-\-threads\fR show messages in a 'threaded' format -- that is, \fB\-t\fR, \fB\-\-threads\fR show messages in a 'threaded' format -- that is,

View File

@ -130,9 +130,9 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts, GError **err)
qflags = MU_QUERY_FLAG_NONE; qflags = MU_QUERY_FLAG_NONE;
if (opts->reverse) if (opts->reverse)
qflags |= MU_QUERY_FLAG_DESCENDING; qflags |= MU_QUERY_FLAG_DESCENDING;
if (opts->skip_dups) if (!opts->include_dups)
qflags |= MU_QUERY_FLAG_SKIP_DUPS; qflags |= MU_QUERY_FLAG_SKIP_DUPS;
if (opts->include_related) if (!opts->skip_related)
qflags |= MU_QUERY_FLAG_INCLUDE_RELATED; qflags |= MU_QUERY_FLAG_INCLUDE_RELATED;
if (opts->threads) if (opts->threads)
qflags |= MU_QUERY_FLAG_THREADS; qflags |= MU_QUERY_FLAG_THREADS;

View File

@ -211,12 +211,24 @@ config_options_group_find (void)
"use a bookmarked query", "<bookmark>"}, "use a bookmarked query", "<bookmark>"},
{"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse, {"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse,
"sort in reverse (descending) order (z -> a)", NULL}, "sort in reverse (descending) order (z -> a)", NULL},
{"skip-dups", 'u', 0, G_OPTION_ARG_NONE, /* default is to skip dups (messages with the same message-id);
&MU_CONFIG.skip_dups, * option left for backward compatibility */
{"skip-dups", 'u', G_OPTION_FLAG_HIDDEN|G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &MU_CONFIG.include_dups,
"show only the first of messages duplicates (false)", NULL}, "show only the first of messages duplicates (false)", NULL},
{"include-related", 'r', 0, G_OPTION_ARG_NONE, {"include-dups", 'u', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.include_related, &MU_CONFIG.include_dups,
"include related messages in results (false)", NULL}, "do not skip all but the first message with some message-id",
NULL},
/* default is to include related messages; option left for
* backward compatibility */
{"include-related", 'r', G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &MU_CONFIG.skip_related,
"include related messages in results", NULL},
{"skip-related", 'r', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.skip_related,
"do not include related messages in the results (false)", NULL},
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir, {"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir,
"output as symbolic links to a target maildir", "<dir>"}, "output as symbolic links to a target maildir", "<dir>"},
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks, {"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks,

View File

@ -140,12 +140,11 @@ struct _MuConfig {
gchar *exec; /* command to execute on the gchar *exec; /* command to execute on the
* files for the matched * files for the matched
* messages */ * messages */
gboolean skip_dups; /* if there are multiple gboolean include_dups; /* if there are multiple messages with
* messages with the same * the same msgid, show all of them,
* msgid, show only the first * not just the first */
* one */ gboolean skip_related; /* do not include related messages in
gboolean include_related; /* included related messages * results */
* in results */
/* for find and cind */ /* for find and cind */
time_t after; /* only show messages or time_t after; /* only show messages or
* addresses last seen after * addresses last seen after

View File

@ -88,7 +88,7 @@ search (const char* query, unsigned expected)
{ {
gchar *cmdline, *output, *erroutput; gchar *cmdline, *output, *erroutput;
cmdline = g_strdup_printf ("%s find --muhome=%s %s", cmdline = g_strdup_printf ("%s find --muhome=%s %s --skip-related --include-dups",
MU_PROGRAM, DBPATH, query); MU_PROGRAM, DBPATH, query);
if (g_test_verbose()) if (g_test_verbose())