# MailMirror documentation (if you can call it that:-) and
# configuration file.

# Description

# This script makes it possible to read mail with several Mail
# Readers, as long as they use the `mbox' Unix standard format.
# It creates a hierarchical directory tree mirroring a subset of another
# tree, wherever a positive mailbox identification is found as a result of
# user tweaking their hierarchy to suit their mailbox needs

# It can rebuild the whole hierarchy or add a single mailbox to an
# existing hierarchy. Current bug: there is no option to remove a single
# mailbox from it, but if you study the hierarchy structure for your
# Mail Reader at the end of the script, then you can issue a single rm
# command and get rid of it. Well, things that are easily done by hand
# will wait for the next version, who knows when...

# It's very easy to deal with plain-folder, hierarchical-structure
# Mail Readers: a simple duplication of the directory hierarchy plus
# the necessary mailbox [symbolic] links are all it takes. For other Mail
# Readers, a supporting structure is needed to complement the mirrored
# structure. By default, mailboxes need to be called "mail" or have
# the ".mail" extension to be recognised as such, but this can easily
# be changed by the user by seting `MailboxNames' and
# `MailboxExtensions'. I, for instance, use the default both for
# mailmirror and my own recognition of the file while brosing my file
# hierarchy. So, whenever I wish to avoid a particular mailbox from
# being added to the mail hierarchy, I simply add a ".d" (short for
# disabled) extension to those mailbox files. That way I still know
# they're mailbox files. I also use other tricks to avoid whole
# sub-hierarchies from being added to the folder hierarchy, which are
# exemplified later in this config file.

# Customization required by users:

# - define variables in the section "variable initialization" below

# Variable initialization section

# IMPORTANT: All directory definitions must be absolute pathnames!
# Use `$HOME' to shorten variable definitions whenever the variable
# definition takes more than one argument and quotes (`""') are needed...
# I couldn't make "~" to be usable on composite variables, so you've got 
# to stick to $HOME...

# Usually, `OrigDir' is your homedir, and `MirrorDir' is a direct 
# subdir of your homedir. In fact, however, `MirrorDir' is actually a 
# set of dirs for each kind of Mail Reader
# Each `MirrorDir' takes the basename plus an appropriate extension:
# `.hierarchy' for Netscape4, Balsa and other plain hierarchy readers
# `.thunderbird' for Thunderbird
# `.kmail' for KMail
# `.evolution2' for Evolution2
# It's not advisable to set `MainDir' the same as `OrigDir'; I just didn't
# try to see what mess might result from it.

# Initial variables, usually OK for everybody

# MainDir is where the main mailboxes should reside (Inbox, Sentbox and 
# similar ones). Set your Mail Reader's base dir to the appropriate directory
# (e.g. MirrorDirMozilla, that is, $MirrorDir.mozilla), since this script 
# will make links from there pointing to those main mailboxes in MainDir.

MainDir=$HOME/m

# Names and extensions for mailboxes
# Include other names and extensions by changing the variables
# according to shell syntax.
MailboxNames="mail"
MailboxExtensions=".mail"
# Directory names that exclude everything inside them.
# Usually created inside other dirs that have a lot of items, and for
# which a finer-grain control is needed. Items that are not to be
# added to the folder hierarchy may then be moved to these special
# directories. These names are the full directory names, that is, not
# pathnames or patterns, to be excluded
ExcludeDirNames="inactives"

OrigDir=$HOME
# putting the hierarchy on a different filesystem may break a few
# things, for instance, the Inbox link for KMail
MirrorDir=$HOME/.mailmirror
# Don't touch these...
MirrorDirHierarchy="${MirrorDir}.hierarchy"
MirrorDirThunderbird="${MirrorDir}.thunderbird"
MirrorDirKMail="${MirrorDir}.kmail"
MirrorDirEvolution2="${MirrorDir}.evolution2"

# Evaluation order for inclusion and exclusion of files in the mailbox
# hierarchy

# First, the mailboxes in ExclusiveDirs are added. These are
# hierarchies where all files are normally to be added to the mailbox
# hierarchy. Names starting with '.' are automatically excluded (shell
# code). The only possible user exclusions from this list are the
# hierarchies inside dirs whose names are exactly one of the dirs
# listed in ExcludeDirNames. There is no further processing for the
# files added here, nor do this processing apply to the second phase
# (below). I normally put these hierarchies inside a directory
# specially reserved for them.

# Secondly, files from the hierarchies in IncludeDirs are added. From
# the primary list obtained by find'ing, names starting with '. ' are
# excluded, then are which are inside ExcludeDirNames items (these are
# to be considered as general rules applied in all search
# directories), Next are excluded the ones inside ExcludedDirs, which
# are supposed to be specific directoy names, given as full
# pathnames. Of the file list so obtained, only those files which
# exactly match the MailboxNames and those whose suffixes match one of
# MailboxExtensions are considered as mailboxes ans so added to the
# mailbox hierarchy.

# Section for name configuration by the user.

# The user can define hierarchies exclusively dedicated to mailboxes, 
# i.e. where mailboxes can have any name (all files are supposed to be
# mailboxes).

ExclusiveDirs="$HOME/m/family $HOME/m/lord $HOME/m/pessoas $HOME/m/security $HOME/m/singles $HOME/ic/orgaos"

# The user can define the hierarchies where the system will look for 
# mailboxes:

IncludeDirs="$HOME/bancas $HOME/compras $HOME/cursos $HOME/ic $HOME/m $HOME/papers $HOME/projetos $HOME/software"

# Sub-hierarchies can be excluded from the `IncludeDirs' list
# Comment out the variable definition if not needed, since a null string 
# will break `find's syntax.

ExcludeDirs="$HOME/bin $HOME/cmd $HOME/cartas $HOME/docs $HOME/evolution $HOME/financas $HOME/hardware $HOME/imagens $HOME/info $HOME/Lis $HOME/listas $HOME/Lord $HOME/mac $HOME/Mail $HOME/medicos $HOME/net $HOME/office $HOME/outros $HOME/security $HOME/templates $HOME/projetos/old-e $HOME/projetos/old-p $HOME/projetos/portugal $HOME/projetos/referee $HOME/projetos/semish $HOME/tmp $HOME/usenix $HOME/w"

# End of variable initialization section

# Initial care to be taken with your Mail Reader and its default mailboxes

# How to configure each Mail Reader to have the desired base directory
# (all the `MirrorDir*' dirs)

# Balsa
# Choose the base directory either durign first configuration (dialog)
# or edit ~/.gnome/balsa appropriately.
# Can be edited later

# Thunderbird
# Thunderbird -> Mail & Newsgroups -> Edit -> Mail & Newsgroups Account Settings
# -> Server Settings -> Local Directory
# Can be edited later

# KMail
# Create a ~/Mail link pointing to the desired MirrorDirKMail
# Notice, however, that kmail insists on thrashing the inbox's
# softlink, which means you have to manually save the inbox before
# switching to another mail reader.

# Evolution2
# Run Evolution first, so that it creates the required dir tree
# other fixes might be required, as is the case for Evolution.
# Then, remove ~/.evolution/mail/local and make it a symlink to
# ~/.mailmirror.evolution2 
# On re-invocation, Evolution should find everything (both Inbox and
# other local mboxes, and the folder hierarchy
