From a39668e00b46333aeb06b5eae4dcc4b8f9c94b63 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 28 Dec 2019 11:19:12 +0200 Subject: [PATCH] add 'mfind' command, like 'find' with mu4e defaults Add a command 'mfind' which follows the mu4e defaults, i.e. --include-related, --skip-dups. --- man/Makefile.am | 14 ++++++++++++-- man/mu-easy.1 | 1 + man/mu-find.1 | 7 ++++++- mu/mu-config.c | 11 ++++++++++- mu/mu-config.h | 12 +++++------- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/man/Makefile.am b/man/Makefile.am index fc62e9ba..a058c4e2 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,4 +1,4 @@ -## Copyright (C) 2008-2017 Dirk-Jan C. Binnema +## Copyright (C) 2008-2019 Dirk-Jan C. Binnema ## ## 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 @@ -32,4 +32,14 @@ dist_man_MANS = \ mu-script.1 \ mu-verify.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) diff --git a/man/mu-easy.1 b/man/mu-easy.1 index 4025bc1e..630fca60 100644 --- a/man/mu-easy.1 +++ b/man/mu-easy.1 @@ -296,6 +296,7 @@ Dirk-Jan C. Binnema .BR mu (1), .BR mu-index (1), .BR mu-find (1), +.BR mu-mfind (1), .BR mu-mkdir (1), .BR mu-view (1), .BR mu-extract (1) diff --git a/man/mu-find.1 b/man/mu-find.1 index 53e23954..c1166d04 100644 --- a/man/mu-find.1 +++ b/man/mu-find.1 @@ -4,6 +4,8 @@ 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 .B mu find [options] @@ -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 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 \fBmu find\fR starts a search for messages in the database that match @@ -42,7 +47,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 diff --git a/mu/mu-config.c b/mu/mu-config.c index 9660a787..e475d90d 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -172,7 +172,7 @@ config_options_group_index (void) } static void -set_group_find_defaults (void) +set_group_find_defaults () { /* note, when no fields are specified, we use * 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); 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* @@ -462,6 +469,7 @@ cmd_from_string (const char *str) { "find", MU_CONFIG_CMD_FIND }, { "help", MU_CONFIG_CMD_HELP }, { "index", MU_CONFIG_CMD_INDEX }, + { "mfind", MU_CONFIG_CMD_MFIND }, { "mkdir", MU_CONFIG_CMD_MKDIR }, { "remove", MU_CONFIG_CMD_REMOVE }, { "script", MU_CONFIG_CMD_SCRIPT }, @@ -535,6 +543,7 @@ get_option_group (MuConfigCmd cmd) case MU_CONFIG_CMD_EXTRACT: return config_options_group_extract(); case MU_CONFIG_CMD_FIND: + case MU_CONFIG_CMD_MFIND: return config_options_group_find(); case MU_CONFIG_CMD_INDEX: return config_options_group_index(); diff --git a/mu/mu-config.h b/mu/mu-config.h index 2e86ead0..26fcf8da 100644 --- a/mu/mu-config.h +++ b/mu/mu-config.h @@ -34,7 +34,7 @@ G_BEGIN_DECLS #define MU_NOCOLOR "MU_NOCOLOR" -enum _MuConfigFormat { +typedef enum { MU_CONFIG_FORMAT_UNKNOWN = 0, /* for cfind, find, view */ @@ -60,11 +60,9 @@ enum _MuConfigFormat { MU_CONFIG_FORMAT_MQUERY, /* output the mux query */ MU_CONFIG_FORMAT_EXEC /* execute some command */ -}; -typedef enum _MuConfigFormat MuConfigFormat; +} MuConfigFormat; - -enum _MuConfigCmd { +typedef enum { MU_CONFIG_CMD_UNKNOWN = 0, MU_CONFIG_CMD_ADD, @@ -73,6 +71,7 @@ enum _MuConfigCmd { MU_CONFIG_CMD_FIND, MU_CONFIG_CMD_HELP, MU_CONFIG_CMD_INDEX, + MU_CONFIG_CMD_MFIND, MU_CONFIG_CMD_MKDIR, MU_CONFIG_CMD_REMOVE, MU_CONFIG_CMD_SCRIPT, @@ -82,8 +81,7 @@ enum _MuConfigCmd { MU_CONFIG_CMD_VIEW, MU_CONFIG_CMD_NONE -}; -typedef enum _MuConfigCmd MuConfigCmd; +} MuConfigCmd; #define mu_config_cmd_is_valid(C) \