Written by jr6b+@andrew.cmu.edu  Sat Jul 19 02:44:17 EDT 1997

Some ifile users have expressed an interest in using ifile to filter mail
only after they have deemed a message unimportant.  The current ifile
system will only filter mail when it is originally incorporated from the
spool file.  Previously, there was no interface for ifile which would
allow the inbox to be used as a place to store high-priority mail.  ifile
more-or-less required that all mail be filtered upon reception.  By
following the instructions below, it will now be possible to filter mail
after having decided that the mail is no longer of high-priority.

The following goes about describing how one would add a "Filter" button
to EXMH which filters the currently highlighted to the appropriate mailbox
as determined by ifile.

The first order of business is to add entries to your .exmh-defaults file
which will add a "Filter" button and have it call a procedure for performing
the filtering of the current message.  Here are the lines you would add:

*Mops.ubuttonlist: ifilter
*Mops.ifilter.text: Filter
*Mops.ifilter.command: Msg_Filter
*Mops.ug_nodraft: ifilter
*Mops.ug_current: ifilter

The second part is a short piece of tcl code which defines the Msg_Filter
procedure described above.  This function will pass the current message
to ifilter, thus placing it in another folder, delete the current message
and then update the folder display to highlight mailboxes with new messages
(so you can see where your piece of mail was filtered to :).  To get exmh
to recognize the code below, you need to take the following steps:

1) If you haven't already, create the directory "~/.tk/exmh", which is the
   location you should store all of your custom EXMH code.
2) Put the code listed below into a file named msg.tcl (or any other file
   with a .tcl tag).
3) Run wish and type in the following commands at the wish command prompt:

   % auto_mkindex ~/.tk/exmh *.tcl
   % exit

   This will have tcl index all the *.tcl code in ~/.tk/exmh so that it will
   be used in place of the standard EXMH functions whenever exmh is run.

------msg.tcl--------------------------------
# this procedure filters a message into what is hopefully the appropriate
# folder
proc Msg_Filter {} {
    global ftoc exmh mhProfile

    # change the following to the location of the ifilter binary
    # just put "ifilter" if the executable is in your path
    set exmh(ifilter) "ifilter"

    set msg_num [Ftoc_MsgNumber $ftoc(curLine)]

    Exmh_Status "ifile filter ..."

    if [catch {exec $exmh(ifilter) < "$mhProfile(path)/$exmh(folder)/$msg_num"} err] {
	Exmh_Debug Inc_iFile: $err
    } else {
	Msg_Remove
	Flist_FindUnseen 1
    }   
}
------msg.tcl--------------------------------

Once you have that done, you can set your default incorporate method to
"inbox" and whenever you have a read message which you want ifile to
filter, simply highlight that message and then click the Filter button.

Enjoy,

Jason Rennie                                       jr6b+@andrew.cmu.edu
       School of Computer Science - Carnegie Mellon University
  Text Learning - Table Tennis - Fencing - Linux - ifile - Prog Rock

