counsel-mairix is an Ivy interface for rapidly going through Mairix search results. Mairix is a very fast mail searching program. Combining it with an ivy completion interface, you can search your emails interactively in the minibuffer, results update as you type. Additionally, if you're looking at an email, you can quickly insert search terms based on the email.
By default, Mairix works by saving the search results into a separate file, like a unix Mbox file, and then you point your email program to that file to display the result. This can be quite inconvenient, since you have to reopen the search mailbox every time your search query changes. Using Ivy, we can now interactively refine our search and view the results in real time.
Currently this is very much a work in progress. counsel-mairix depends on the Emacs Interface for Mairix which is bundled with Emacs. It should work out of the box by invoking M-x counsel-mairix if you have configured it properly (see Installation below).
Patches are welcome! Please note that this package is intended to be a part of GNU ELPA, thus for patches over >15 lines your FSF paperwork ought to be in order. Please mail patches to my public inbox at ~firstname.lastname@example.org.
Mairix running on (mostly) the September 2020 archive of email@example.com in Mbox format.
A prerequisite on the system is obviously that Mairix is installed and configured properly. See (mairix-el) Configuring mairix.
Since this is still alpha quality software, it is not available in any package repository. Thus clone it somewhere in your system and add it to your load path:
(add-to-list 'load-path "<path-to-this-repo>")
You can do this using use-package:
(use-package counsel-mairix :load-path <path>)
If you have the Emacs Interface for Mairix configured properly then this should work without any additional configuration. Otherwise, you need to configure it. For example, if you use Mairix with Mbox format results, configure it like this:
(setq mairix-file-path "~/mail") ;; The folder where the search file is stored (setq mairix-search-file "search.mbox") ;; Name of the search file itself
The table below lists a summary of the functions in counsel-mairix. Please refer to their documentation in Emacs for more information.
||Run mairix queries interactively|
||Save your searches from your previous
|C-c C-t||Toggle threading|
|C-c C-s i||Insert saved mairix search|
|C-c C-s s||Save current search|
If you're viewing an email in one of the major modes Mairix supports, you can hit these bindings to add them to your search string:
|C-c C-f f||Yank the
|C-c C-f s||Yank the
|C-c C-f t||Yank the
|C-c C-f i||Yank the
Remember that the default binding M-j (
ivy-yank-word) to yank
things your cursor is on to insert it into the minibuffer.
With a negative prefix argument (M-- or C-u -), insert a
negated search of the form
f:~firstname.lastname@example.org which would search messages
not matching that address. This also applies for avy searches below.
If avy is installed, the following avy search refinements are available.
|C-c C-a t||Avy pick one
|C-c C-a c||Avy pick one
|C-c C-a s||Avy pick one word from
|C-c C-a b||Avy pick one word from the body and insert into the search|
|C-c C-a a||Avy pick any word from the message and insert into the search|
With the prefix argument, it will insert the respective mairix search pattern
From) before the picked item. If the pattern is already inserted,
the pattern is refined, i.e. if the search string is
t:email@example.com, picking a
firstname.lastname@example.org will turn it into
the prefix argument is given, in which case a new pattern is inserted, turning
t:email@example.com t:firstname.lastname@example.org. This does not apply for yanking anything.
Here, I'm interested in emacs-devel discussions about key bindings, so I start
by creating a subject search term using
s:. I yank the words
bindings using avy, note that the second yank inserts a comma to create a
search of the form
s:key,binding which matches when both
are mentioned. Then I'm also interested in what Stefan Monnier and Eli Zaretskii
have to say about it, so I insert
f: and yank one of the
Cc targets using
C-a C-c c and then add an OR search using
/ and then insert the
C-c C-f t. Finally, I'm just interested in what Stefan and Eli have to
say about it, so I toggle threads OFF using
counsel-mairix defines the following customization variables:
Override the mail program used to create the Ivy search buffer.
This setting can override which mail program you are normally using for Mairix
searches defined in
mairix-mail-program. This can be useful if you want
traditional Mairix searches to use some mail program (e.g. Gnus) but prefer
another program to display the Ivy buffer.
It defaults to the value of
(setq counsel-mairix-mail-frontend 'rmail)
This would force counsel-mairix to use Rmail for displaying the search buffer.
Whether to prompt for including threads in the Mairix search. Mairix.el defaults to querying every time, but I found this behaviour annoying.
Set it to
'promptto ask every time (the default)
tto always include threads
nilto never include threads.
Gnus and VM aren't supported as display frontends.
These could go into the ticket tracker.
Copyright © Antoine Kalmbach. Licensed under the GNU GPL version 3.