# MAFE: MH Alias File Editor

by Andrew Billyard (andrew_billyard@alumni.REMOVETHISBIT.uwaterloo.ca)

##

1. Introduction
2. Installation
3. Terminology
4. Usage
5. Issues

## Introduction

MAFE is a Perl+Tk utility which manipulates the nmh alias file(s). It can add email aliases, delete them and change them. It is similar in style to `aliases.tcl` by Brent Welch and Scott Stanton in the standard exmh package, but has a little more functionality. Unfortunately, my TCL+TK knowledge is limited and it would have taken me too long to learn the language to do what I wanted to do, so I've used what I know: Perl. However, if anyone wishes to convert this to Tcl, they are most welcome. This is not meant to critize `aliases.tcl` by any means. Indeed, `aliases.tcl` is much faster than mafe and is native to exmh (whereas mafe needs to be called via exec, see below).

mafe uses two features of nmh alias file(s) which is not currently exploited in the exmh alias editor:

1. nmh can allow for several alias files, which are all specified on one line in .mh_profile, namely,
   `AliasFile: .mh_aliases_research .mh_aliases_friends .mh_aliases_family`
2. nmh alias files can the format
   `friends: All-Friends:, friend1@b.com, friend2@c.edu, ... friend@z.ca, ;`
   (note the semicolon at the end as well as the comma usage) so that specifying `friends` in the `To:` field will result in the recipients receiving the mail with `To: All-Friends;` in the header rather than the entire list of emails.

## Terminology

As mentioned above, the nmh file can take one of two basic forms:

1: | `name`: {list}
2: | `name`: `tag`:, {list}, ;

where {list} is a comma separated list of email addresses or other aliases defined later in the file. This help file makes use of the following terminology:

- Alias: An alias will be defined as any line in the alias file in the form of line 1.
- Alias name: The `name` portion of the alias line.
- Distribution: A distribution will be defined as any line in the alias file in the form of line 2.
- Distribution name: The `name` portion of the alias line.
- Tag Any word(s) found in the `tag` location of a Distribution line (line 2). The tag is what the recipients of the email will see in the `To:` field.
- Address Any words found in the comma separated list of both the Alias and Distribution lines. Note that Address may be anther Alias/Distribution found later in the alias file as well as email addresses.

## Installation

Requirements: mafe requires the Perl::Tk modules.

Presently, there is no "installation" procedure (such as compiling or rpm-ing). Simply place uncompress the mafe tar file into a directory seen by the PATH variable. Mafe also comes with script called `exmhmail` (which should also be visible to the PATH environment) which launches a compose session in exmh.

To add mafe to exmh, add the following to the beginning of `exmh-defaults`

`*Main.addr.text: Address... *Main.addr.m.entrylist: alias alias2 addr *Main.addr.m.l_alias: MH Aliases *Main.addr.m.c_alias: Aliases_Pref *Main.addr.m.l_alias2: MH Alias File Editor (MAFE) *Main.addr.m.c_alias2: exec /path to mafe/mafe \$address & *Main.addr.m.l_addr: Address Book *Main.addr.m.c_addr: Addr_Browse`

## Usage

The program `mafe` can be called from within `exmh` (as described above) or can be called on its own via
`mafe address` where `address` will appear in the Addresses' Entry Box(see below).

When it first starts, `mafe` first reads `$HOME/.exmh/exmh-defaults` to obtain which fonts are used by `exmh`. Next, it reads the file `$HOME/.mh_profile` and looks for the alias file names given in the line starting with `AliasFile:`. It then proceeds to open the first alias file mentioned on that line.

### Layout

A screen shot of `mafe` is given below.
In the upper right corner are several buttons whose meaning is pretty much self-explanatory.
The name of the nmh alias file is displayed at the upper left.
If there are more than one nmh alias (as specified in `.mh_profile`) then the label is replaced with a pull down combo-box to switch between different files. Note: if a change has been made to an alias file and has not been saved, then either selecting a different alias file or clicking the Dismiss dismiss button will result in the user to be prompted to save the file first.

Left Side: On the left hand side of the window there are two nearly-identical units above one another. Each unit contains: a list box, an entry box and a row of buttons. With the exception of the last button in each set, all look the same. The upper unit is reserved for aliases (as defined in the Introduction) while the lower unit is reserved for the distributions (again, as defined in the Introduction).

Alias unit (upper). | Distribution unit (lower).

1. List Box: This box will display all the aliases/distributions defined in the alias file. Clicking a particular alias/distribution in this box will list all of the associated addresses in the list box on the right hand side (see below).
2. Entry Box: Any changes to be made to an alias or distribution is to be put into the entry box.
3. Buttons:
   1. Comp: If a particular item in the list box is selected and the Comp button is pressed, `mafe` launches a compose sedit window from within `exmh`. The `To:` field will be filled in with the List Box's selection.
   2. Insert: Inserts whatever is in the Entry Box (if not empty) into the List Box and generates a new alias/distribution. Any addresses to be added will be done on the right hand frame (see below).
   3. Change: If an entry is selected in the List Box and the Entry Box is not empty, the two values will be swapped.
   4. Delete: Delete the selection in the List Box.
   5. Alias or Distro: If the selection is a distribution, it (and its addresses) will be moved to the Alias unit. Similarly for aliases. However, distributions require an addition distribution tag (see Introduction) and the default value of "`Undisclosed Recipients`" will be used. This value can be changed in the right hand frame (see below).

Right Side Frame: In this frame, changes can be made to the addresses belonging to the selected alias/distribution.

1. Distro. Tag Entry Box: This box remains inactive if an alias is selected. If a distribution is selected, this box becomes active and displays the distribution's tag.
2. Set Button: If the user changes the distribution's tag (in the Entry Box), this button will become active. Click to permanently change the distribution's tag.
3. List Box: Once an alias/distribution is selected on the left side, its addresses will be displayed in this box.
4. Entry Box: Any changes to be made to an address is to be put into the entry box.
5. Buttons:
   1. Insert: Adds whatever is in the Entry Box (if not empty) to the list of addresses in the List Box.
   2. Change: If an entry is selected in the List Box and the Entry Box is not empty, the two values will be swapped.
   3. Delete: Delete the selection in the List Box.
   4. Expand: If a particular address is selected and it is an alias/distribution, clicking Expand will substitute the address with the addresses found in the corresponding alias/distribution. If no item is selected in the list box, Expand will perform a similar operation on all addresses in the list box which are aliases/distributions. Note, Expand only expands alias/distribution which are defined in the current alias file being edited. For example if an alias contains the alias "john", "john" will only be expanded if it is defined in the current file.
   5. Contract: This is nearly the opposite of Expand. Like Expand, it will operate only on one address if it is selected, otherwise it will operate on all addresses in the list box. However, Contract is careful about what it contracts. In particular, it operates on an address if and only if:
      - the email address is explicitly defined in another alias/distribution in the current file and
      - this other alias/distribution in which the email address is defined has, at most, three addresses in its definition.
      This is a bit terse, but for a good reason. To demonstrate why, consider the following alias file:
      `

      ProjectList: | jordan1@home.ca, jordan2@work.ca, tracy@foo.bar
      Jordan: | jordan1@home.ca, jordan2@work.ca, jordan3@laptop.com
      DistroList: | tracy@foo.bar, hans@down.de, einstein@hair.com, \
      | fred@rick.com, apple@day.ca, ... , person100@years.old

      ` Now, suppose the `ProjectList` alias was selected and the Contract button pressed. If there were not a three-address limit, the alias would then read
      `

      ProjectList: Jordan, DistroList

      ` and so all of `DistroList` is included in `ProjectList` and not just `tracy@foo.bar`. This may not be desirable. With the three-address limit, the line would become `

      ProjectList: Jordan, tracy@foo.bar

      ` (note, that `Jordan` contains one more email address than what was in the original `ProjectList`. This might be ok if all the addresses in `Jordan` belongs to the same person). Really, Contract is meant to replace several email addresses in an alias/distribution which belong to one person only and replace these addresses with an alias or distribution name for brevity. So use with caution.
      If the number 3 is unsatisfactory (i.e., you want the limit to be 2 addresses or 8, etc.), change the line `$UpperLimit=3;`.

## Issues

The following lists a few issues with `mafe`

1. When saving an alias file, `mafe` first saves the distributions in alphabetical order and then the aliases in alphabetical order. It just looks nice to read. However, it does potentially pose a problem since an alias may then be defined before it is used (since in `nmh` an alias needs to be referenced before it is defined). If this is the case, repeat the alias file name in `.mh_profile`:
   `AliasFile: .mh_aliases1 .mh_aliases2 .mh_aliases1 .mh_aliases2`
2. `mafe` was written in Perl with the Tk module. It would have been nice to have written it in Tcl+Tk, so that it would be more native to the exmh package. Perhaps one day I'll sit down and learn Tcl and do this. Anyone up for the challenge of porting is more than welcome.

Andrew Billyard (andrew_billyard@alumni.REMOVETHISBIT.uwaterloo.ca)