add 'mfind' command, like 'find' with mu4e defaults

Add a command 'mfind' which follows the mu4e defaults, i.e.
--include-related, --skip-dups.
This commit is contained in:
Dirk-Jan C. Binnema 2019-12-28 11:19:12 +02:00
parent 8cef8ac69c
commit a39668e00b
5 changed files with 34 additions and 11 deletions

View File

@ -1,4 +1,4 @@
## Copyright (C) 2008-2017 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ## Copyright (C) 2008-2019 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## ##
## This program is free software; you can redistribute it and/or modify ## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by ## it under the terms of the GNU General Public License as published by
@ -32,4 +32,14 @@ dist_man_MANS = \
mu-script.1 \ mu-script.1 \
mu-verify.1 \ mu-verify.1 \
mu-view.1 \ mu-view.1 \
mu.1 mu.1 \
$(BUILT_SOURCES)
BUILT_SOURCES= \
mu-mfind.1
mu-mfind.1: mu-find.1
cp -f $< $@
CLEANFILES= \
$(BUILT_SOURCES)

View File

@ -296,6 +296,7 @@ Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
.BR mu (1), .BR mu (1),
.BR mu-index (1), .BR mu-index (1),
.BR mu-find (1), .BR mu-find (1),
.BR mu-mfind (1),
.BR mu-mkdir (1), .BR mu-mkdir (1),
.BR mu-view (1), .BR mu-view (1),
.BR mu-extract (1) .BR mu-extract (1)

View File

@ -4,6 +4,8 @@
mu find \- find e-mail messages in the \fBmu\fR database. mu find \- find e-mail messages in the \fBmu\fR database.
mu mfind \- find e-mail messages in the \fBmu\fR database with mu4e defaults.
.SH SYNOPSIS .SH SYNOPSIS
.B mu find [options] <search expression> .B mu find [options] <search expression>
@ -13,6 +15,9 @@ mu find \- find e-mail messages in the \fBmu\fR database.
\fBmu find\fR is the \fBmu\fR command for searching e-mail message \fBmu find\fR is the \fBmu\fR command for searching e-mail message
that were stored earlier using \fBmu index\fR(1). that were stored earlier using \fBmu index\fR(1).
\fBmu mfind\fR is a version of \fBmu find\fR that defaults to
\f--include-related\fR and \fB--skip-dups\fR, just like \fBmu4e\fR does.
.SH SEARCHING MAIL .SH SEARCHING MAIL
\fBmu find\fR starts a search for messages in the database that match \fBmu find\fR starts a search for messages in the database that match

View File

@ -172,7 +172,7 @@ config_options_group_index (void)
} }
static void static void
set_group_find_defaults (void) set_group_find_defaults ()
{ {
/* note, when no fields are specified, we use /* note, when no fields are specified, we use
* date-from-subject, and sort descending by date. If fields * date-from-subject, and sort descending by date. If fields
@ -190,6 +190,13 @@ set_group_find_defaults (void)
get_output_format (MU_CONFIG.formatstr); get_output_format (MU_CONFIG.formatstr);
expand_dir (MU_CONFIG.linksdir); expand_dir (MU_CONFIG.linksdir);
if (MU_CONFIG.cmd == MU_CONFIG_CMD_MFIND) {
/* 'mfind' --> find with mu4e defaults */
MU_CONFIG.include_related = TRUE;
MU_CONFIG.skip_dups = TRUE;
MU_CONFIG.cmd = MU_CONFIG_CMD_FIND;
}
} }
static GOptionGroup* static GOptionGroup*
@ -462,6 +469,7 @@ cmd_from_string (const char *str)
{ "find", MU_CONFIG_CMD_FIND }, { "find", MU_CONFIG_CMD_FIND },
{ "help", MU_CONFIG_CMD_HELP }, { "help", MU_CONFIG_CMD_HELP },
{ "index", MU_CONFIG_CMD_INDEX }, { "index", MU_CONFIG_CMD_INDEX },
{ "mfind", MU_CONFIG_CMD_MFIND },
{ "mkdir", MU_CONFIG_CMD_MKDIR }, { "mkdir", MU_CONFIG_CMD_MKDIR },
{ "remove", MU_CONFIG_CMD_REMOVE }, { "remove", MU_CONFIG_CMD_REMOVE },
{ "script", MU_CONFIG_CMD_SCRIPT }, { "script", MU_CONFIG_CMD_SCRIPT },
@ -535,6 +543,7 @@ get_option_group (MuConfigCmd cmd)
case MU_CONFIG_CMD_EXTRACT: case MU_CONFIG_CMD_EXTRACT:
return config_options_group_extract(); return config_options_group_extract();
case MU_CONFIG_CMD_FIND: case MU_CONFIG_CMD_FIND:
case MU_CONFIG_CMD_MFIND:
return config_options_group_find(); return config_options_group_find();
case MU_CONFIG_CMD_INDEX: case MU_CONFIG_CMD_INDEX:
return config_options_group_index(); return config_options_group_index();

View File

@ -34,7 +34,7 @@ G_BEGIN_DECLS
#define MU_NOCOLOR "MU_NOCOLOR" #define MU_NOCOLOR "MU_NOCOLOR"
enum _MuConfigFormat { typedef enum {
MU_CONFIG_FORMAT_UNKNOWN = 0, MU_CONFIG_FORMAT_UNKNOWN = 0,
/* for cfind, find, view */ /* for cfind, find, view */
@ -60,11 +60,9 @@ enum _MuConfigFormat {
MU_CONFIG_FORMAT_MQUERY, /* output the mux query */ MU_CONFIG_FORMAT_MQUERY, /* output the mux query */
MU_CONFIG_FORMAT_EXEC /* execute some command */ MU_CONFIG_FORMAT_EXEC /* execute some command */
}; } MuConfigFormat;
typedef enum _MuConfigFormat MuConfigFormat;
typedef enum {
enum _MuConfigCmd {
MU_CONFIG_CMD_UNKNOWN = 0, MU_CONFIG_CMD_UNKNOWN = 0,
MU_CONFIG_CMD_ADD, MU_CONFIG_CMD_ADD,
@ -73,6 +71,7 @@ enum _MuConfigCmd {
MU_CONFIG_CMD_FIND, MU_CONFIG_CMD_FIND,
MU_CONFIG_CMD_HELP, MU_CONFIG_CMD_HELP,
MU_CONFIG_CMD_INDEX, MU_CONFIG_CMD_INDEX,
MU_CONFIG_CMD_MFIND,
MU_CONFIG_CMD_MKDIR, MU_CONFIG_CMD_MKDIR,
MU_CONFIG_CMD_REMOVE, MU_CONFIG_CMD_REMOVE,
MU_CONFIG_CMD_SCRIPT, MU_CONFIG_CMD_SCRIPT,
@ -82,8 +81,7 @@ enum _MuConfigCmd {
MU_CONFIG_CMD_VIEW, MU_CONFIG_CMD_VIEW,
MU_CONFIG_CMD_NONE MU_CONFIG_CMD_NONE
}; } MuConfigCmd;
typedef enum _MuConfigCmd MuConfigCmd;
#define mu_config_cmd_is_valid(C) \ #define mu_config_cmd_is_valid(C) \