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
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
\fB\-\-skip\-dups\fR,\fB-u\fR whenever there are multiple messages with the
same name, only show the first one. This is useful if you have copies of the
same message, which is a common occurrence when using e.g. Gmail together with
\fBofflineimap\fR.
\fB\-\-include\-dups\fR,\fB-u\fR by default, whenever there are multiple
messages with the same name, only show the first one. This is useful if you have
copies of the same message, which is a common occurrence when using e.g. Gmail
together with \fBofflineimap\fR. Use this option to turn that behavior off.
.TP
\fB\-\-include\-related\fR,\fB-r\fR also include messages being refered to by
the matched messages -- i.e.. include messages that are part of the same
message thread as some matched messages. This is useful if you want
Gmail-style 'conversations'. Note, finding these related messages make
searches slower.
\fB\-\-skip\-related\fR,\fB-r\fR by default, the results include messages being
refered to by the matched messages -- i.e.. include messages that are part of
the same message thread as some matched messages. This is useful if you want
Gmail-style 'conversations'. Note, finding these related messages make searches
slightly slower. Use this option to turn that behavior off.
.TP
\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;
if (opts->reverse)
qflags |= MU_QUERY_FLAG_DESCENDING;
if (opts->skip_dups)
if (!opts->include_dups)
qflags |= MU_QUERY_FLAG_SKIP_DUPS;
if (opts->include_related)
if (!opts->skip_related)
qflags |= MU_QUERY_FLAG_INCLUDE_RELATED;
if (opts->threads)
qflags |= MU_QUERY_FLAG_THREADS;

View File

@ -211,12 +211,24 @@ config_options_group_find (void)
"use a bookmarked query", "<bookmark>"},
{"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse,
"sort in reverse (descending) order (z -> a)", NULL},
{"skip-dups", 'u', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.skip_dups,
/* default is to skip dups (messages with the same message-id);
* 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},
{"include-related", 'r', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.include_related,
"include related messages in results (false)", NULL},
{"include-dups", 'u', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.include_dups,
"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,
"output as symbolic links to a target maildir", "<dir>"},
{"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
* files for the matched
* messages */
gboolean skip_dups; /* if there are multiple
* messages with the same
* msgid, show only the first
* one */
gboolean include_related; /* included related messages
* in results */
gboolean include_dups; /* if there are multiple messages with
* the same msgid, show all of them,
* not just the first */
gboolean skip_related; /* do not include related messages in
* results */
/* for find and cind */
time_t after; /* only show messages or
* addresses last seen after

View File

@ -88,7 +88,7 @@ search (const char* query, unsigned expected)
{
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);
if (g_test_verbose())