diff --git a/NEWS.org b/NEWS.org index 4f39924f..e1b63fd6 100644 --- a/NEWS.org +++ b/NEWS.org @@ -8,6 +8,14 @@ - ~mu~ commands ~extract~, ~verify~ and ~view~ can now read the message from standard input; see their man-pages for details + - ~mu init~ gained the ~--ignored-address~ option for email-addresses / regexps + that should _not_ be included in the contacts-cache (i.e., for ~mu cfind~ and + Mu4e address completion). See the ~mu-init~ manpage for details. + + It's not unusual for 'noreply`-type e-mail addresses to be the majority in + an e-mail corpus, so it useful to get rid of those, with + '=--ignored-address=/.*noreply*/'= + - experimental: if you build ~mu~ with [[https://github.com/CLD2Owners/cld2][CLD2]] support (available in many Linux distros), ~mu~ will try to detect the language of the body of e-mail messages; you can then search by their ISO-639-1 code, e.g. ~mu find diff --git a/lib/mu-contacts-cache.cc b/lib/mu-contacts-cache.cc index 532a336b..61bbb2be 100644 --- a/lib/mu-contacts-cache.cc +++ b/lib/mu-contacts-cache.cc @@ -188,8 +188,6 @@ ContactsCache::Private::serialize() const dirty_ = 0; } - - ContactsCache::ContactsCache(Config& config_db) : priv_{std::make_unique(config_db)} {} @@ -381,9 +379,6 @@ ContactsCache::is_ignored(const std::string& addr) const return address_matches(addr, priv_->ignored_plain_, priv_->ignored_rx_); } - - - #ifdef BUILD_TESTS /* * Tests. diff --git a/man/mu-init.1.org b/man/mu-init.1.org index a69db892..148d46dc 100644 --- a/man/mu-init.1.org +++ b/man/mu-init.1.org @@ -21,24 +21,38 @@ starts searching at ==. By default, *mu* uses whatever the *MAILDIR* environment variable is set to; if it is not set, it tries =~/Maildir= if it already exists. -** --my-address= +** --my-address= -specifies that some e-mail addresses are 'my-address' (the option can be used +specifies that some e-mail address is 'my-address' (the option can be used multiple times). Any message in which at least one of the contact fields contains such an address is considered a 'personal' messages; this can then be used for filtering in *mu-find(1)*, *mu-cfind(1)* and *mu4e*, e.g. to filter-out mailing list messages. -== can be either a plain e-mail address (such as +== can be either a plain e-mail address (such as *foo@example.com*), or a basic PCRE regular-expression (see *pcre(3)* for details), wrapped in */* (such as =/foo-.*@example\\.com/=). Depending on your shell, the argument may need to be quoted. +** --ignored-address= + +specifies that some e-mail address is to be ignored from the contacts-cache +(the option can be used multiple times). Such address then cannot be found with +*mu-cfind(1)* or in the Mu4e contacts cache. + +== can be either a plain e-mail address or a regexp, just like +for the =--my-address= option. + ** --reinit -reinitialize the database from an earlier version; that is, create a new -empty database witht the existing settings. This cannot be combined -with the other ~init~ options. +reinitialize the database from an earlier version; that is, create a new empty +database with the existing settings. This cannot be combined with the other ~init~ +options. + +* EXAMPLE +#+begin_example +$ mu init --maildir=~/Maildir --my-address=alice@example.com --my-address=bob@example.com --ignored-address='/.*reply.*/' +#+end_example #+include: "exit-code.inc" :minlevel 1 diff --git a/mu/mu-cmd-info.cc b/mu/mu-cmd-info.cc index 3f4bb577..60095f56 100644 --- a/mu/mu-cmd-info.cc +++ b/mu/mu-cmd-info.cc @@ -49,7 +49,6 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts) return "never"; else return time_to_string("%c", t); - }; Table info; @@ -61,8 +60,11 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts) info.add_row({"max-message-size", format("%zu", conf.get())}); info.add_row({"batch-size", format("%zu", conf.get())}); info.add_row({"created", tstamp(conf.get())}); + for (auto&& c : conf.get()) info.add_row({"personal-address", c}); + for (auto&& c : conf.get()) + info.add_row({"ignored-address", c}); info.add_row({"messages in store", format("%zu", store.size())}); info.add_row({"last-change", tstamp(store.statistics().last_change)}); diff --git a/mu/mu-cmd-init.cc b/mu/mu-cmd-init.cc index 84b0fb19..78ec1e52 100644 --- a/mu/mu-cmd-init.cc +++ b/mu/mu-cmd-init.cc @@ -46,10 +46,15 @@ Mu::mu_cmd_init(const Options& opts) MemDb mdb; Config conf{mdb}; + if (opts.init.max_msg_size) conf.set(*opts.init.max_msg_size); if (opts.init.batch_size) conf.set(*opts.init.batch_size); + if (!opts.init.my_addresses.empty()) + conf.set(opts.init.my_addresses); + if (!opts.init.ignored_addresses.empty()) + conf.set(opts.init.ignored_addresses); return Store::make_new(opts.runtime_path(RuntimePath::XapianDb), opts.init.maildir, conf); @@ -67,4 +72,3 @@ Mu::mu_cmd_init(const Options& opts) return Ok(); } - diff --git a/mu/mu-options.cc b/mu/mu-options.cc index 4058f748..0d466649 100644 --- a/mu/mu-options.cc +++ b/mu/mu-options.cc @@ -383,8 +383,12 @@ sub_init(CLI::App& sub, Options& opts) "Top of the maildir") ->type_name(""); sub.add_option("--my-address", opts.init.my_addresses, - "Personal e-mail addresses") + "Personal e-mail address or regexp") ->type_name("
"); + sub.add_option("--ignored-address", opts.init.ignored_addresses, + "Ignored e-mail address or regexp") + ->type_name("
"); + sub.add_option("--max-message-size", opts.init.max_msg_size, "Maximum allowed message size in bytes"); sub.add_option("--batch-size", opts.init.batch_size, @@ -393,6 +397,7 @@ sub_init(CLI::App& sub, Options& opts) "Re-initialize database with current settings") ->excludes("--maildir") ->excludes("--my-address") + ->excludes("--ignored-address") ->excludes("--max-message-size") ->excludes("--batch-size"); } diff --git a/mu/mu-options.hh b/mu/mu-options.hh index 25210fd4..8b399acf 100644 --- a/mu/mu-options.hh +++ b/mu/mu-options.hh @@ -184,6 +184,8 @@ struct Options { struct Init { std::string maildir; /**< where the mails are */ StringVec my_addresses; /**< personal e-mail addresses */ + StringVec ignored_addresses; /**< addresses to be ignored for + * the contacts-cache */ OptSize max_msg_size; /**< max size for message files */ OptSize batch_size; /**< db transaction batch size */ bool reinit; /**< re-initialize */