Virtual Folders in Mutt

Wiki source

Search the scratchpad:  

A long time ago, I sent a wishlist bug report about Mutt for support of virtual folders:

680: Opening/searching several folders at once Package: mutt; Severity: wishlist; Reported by: Hugo Haas <hugo@larve.net>; 689 days old.

I have discovered today that it is possible with an external program: Mairix.

Since I have two sets of folders and need to index them before doing a search, I have written a script to do so:

#! /bin/sh
#
# Usage: mairix-index (mail|private-mail) ...
#
# (c) 2003 Hugo Haas http://larve.net/people/hugo/
# Created 5 July 2003

MAIRIX=mairix
RM=/bin/rm

if [ $# -lt 1 ]; then
  exit 1
fi

TEMPCONF=/tmp/mairixrc-temp-hh.$$
trap "$RM -f $TEMPCONF; exit" 0 1 2 3 15

cat << EOF > $TEMPCONF
base=$HOME/$1
database=$HOME/.mairix_index_$1
vfolder=archives/vfolder
EOF
echo "folders=`ls $HOME/$1 | grep -v -F 'archives/' | tr -d / | xargs echo | tr \  :`" >> $TEMPCONF
shift
echo "Created $TEMPCONF as a mairixrc:"
cat $TEMPCONF

echo "Updating index"
$MAIRIX -f $TEMPCONF -p

echo "Running mairix search:"
$MAIRIX -f $TEMPCONF -v "$@"

Then, from Mutt, I have macros to to do a search and see the results:

##########################################################################
# Virtual folders: mairix

  macro index \eM "<shell-escape>$HOME/.mutt/mairix-index BASE " "Run a Mairix search"
  macro index \eF "<change-folder-readonly>=archives/vfolder/\n" "Switch to Mairix virtual folder"

Note: BASE is either mail or private-mail and is set with my M4 muttrc preprocessing.

Then, I can a search for "Hugo" with \eM Hugo and then see the results with \eF.

Hella cool!