mutt, neomutt, and searching emails
zen at freedbms.net
Sat May 9 19:07:51 PDT 2020
There are some ageing dinosauruses that still use TUIs and even the more archaic mbox "all emails in this folder in a single file" email storage, and to distressingly admit to the truly ancient practice of "grep"ing an mbox file when mutt's search feature is just so dang diddly ang dang SLOW on a 20,000+ email folder (and that's barely 4 years of cypherpunks!).
What to do. Well the installation of neomutt many moons ago, which was not accompanied by any man page reading nor even a simple yandex, has not changed the search speed automatically.
Mutt (/neomutt)'s "~b" email body search feature is so slow across 20k emails it's impressive, especially given the speed of grep from the command line, and the speed of opening that 20k email folder.
The following thought arises:
On opening an mbox folder, mutt evidently scans those 20k messages, since it numbers them uniquely, and can jump very quickly to any single email, and also can filter the subjects, senders, recipients etc using it's secret incantations for "L"imiting etc.
So it at least appears that mutt indexes that mbox file by (presumably) line number, and also (again, apparently at least) caches certain of the headers of each email.
If the above assumptions are correct, then searching the body of emails could be done using grep at the command line, and scanning grep's output for line numbers, and mapping that against mutt's internal mapping of the mbox.
Theoretically at least, this is a relatively simple algorithm. But although it's simple, it may be too late given the existence of neomutt which probably just requires some reading, config, and learning the new commands for searching emails using whatever new whizz bang system that puts the neo into neomutt (for the lazy, that would be libnotmuch).
More information about the cypherpunks