  TkMail v1.2  -- A Tk/Tcl interface to Mail
          		by Paul Raines (raines@bohr.physics.upenn.edu)

  This program is still very young so don't trust it without testing!
  Make a backup copy of your ~/mbox file and some of your folders
  and then test out the features on those files.

  INSTALLATION:
      (1) set the first line in tkmail to the location of your wish
      (2) copy the files utils.tk and ispell.tk to the location of 
          your choice and then edit the mf(utils) and mf(spell)
          variables in tkmail to reflect that location
      (3) edit the other user setting in tkmail, particularly mf(cmd),
          mf(nopaging), mf(system), and mf(fdir). Also make sure you
          have the bitmaps in the locations given. See BUGS 
          in tkmail about mf(beep).
      (4) Read the top of the ispell.tk file and follow the 
          installation instruction there.

  COMPATIBILITY:
      I developed this app on a SGI Indigo running IRIX 4.0.5F and
      has only been tested at this time on that system.  This app
      depends on the following working:

          echo "h 1" | Mail -N -f folder
      Lists the headers of messages in folder to standard out. Make
      sure the mf(nopaging) variable is set right in tkmail or you will
      only get the a list of the first screenful of messages.
      On SUN, setting it to "set screen=100000" will do the trick

          echo "2" | Mail -N -f folder
      Displays message 2 on stdout.

          echo "d 3 4 8 9" | Mail -N -f folder
      Deletes messages 3,4,8, and 9 from folder.

          echo "s 4 5 9 24 file" | Mail -N -f folder
      Saves messages 4,5,9, and 24 from folder in file.

          echo "q" | Mail -N
      Prints a message like "Held  4 messages in /usr/mail/raines"
      if you have messages in your system box.

          cat file | sendmail -bm user@machine
      Mails file to user@machine. Note that this bypasses
      the Mail command and therefore options such as 'record'.
      I have created the mf(record) user setting to account
      for this. It might be necessary to hack the mf_recordmsg
      procedure in tkmail to make it fit your mail folder format.

      I you find others that are bypassed and you
      want them included in TkMail, please mail me about it.
      I need to use sendmail for arbitrary header definition.	

      You can change the name of the Mail command in the user
      settings in tkmail, but it must support the structure above.
      If you find that you have to make changes to the code to
      get it to work on your machine, please e-mail me and tell
      me what machine you are on and what changes you made.

  USAGE:
      	tkmail [-iconic] folder &

      Most things in the menu should be self evident (yeah...that is
      what they always say). A few menu items are also on the button
      bar. All menu items can be accessed with the accelerator characters
      using the Alt key or Alt-Shift keys. Because of the hassle of 
      dealing with the system inbox, I have the app incorporate new mail
      into the ~/mbox instead of treating it as just another folder.
      I hope to some day figure out a good way to not have to do this.

      When you get new mail, just click the 'Incorp' button and you
      will be taken to the ~/mbox folder at the first new message.
      The ~/mbox serves as the central place to dish out messages to
      your folders using the copy and move menu items.

      If a ~/.tkmail or ~/tk/tkmail file exists, they are sourced
      so that the individual user can change the User Settings 
      described in tkmail. The knowledgable Tk programmer can also do
      much more customization. One can define a procedure called
      mf_compose_hook in these files that will be evaluated each
      time a compose message window is created. See the included
      example.tkmail.

      Mouse bindings in the header list box are:
          B1 Click - view clicked message and make it the sole selection
          B1 Drag - select additional messages for later possible operations.
          B2 Click - unselect message clicked if not the viewed one.
          B3 Click - select message clicked with viewing.
          B3 Drag - select all messages dragged over.

      The viewed message will always have the '>' character in front of it.
      The Delete, Copy, Move, Save, and Print commands operate on all
      selected messages. The Reply and Forward operate on only the
      currently viewed one.

      For efficiency and undo ability, deletes are not done immediately.
      Deletes are processed when changing folders or quitting. This means
      that if the something kills TkMail, any impending deletes are
      not done.

  IMPLEMENTATION:
      The header list box is not a Tk Listbox but a text widget I hacked
      up so it could support non-contiguous selection. However, because
      it is a text widet, there is no horizontal scrolling.

      Every operation on a folder is a separate system call to the
      Mail command. It would be much more efficient to use one open
      pipeline command, but in standard Tcl, if one does a gets when
      there is nothing to get, the app hangs. As I see it, I have three
      choices which I list below in the order of my preference.

          1) Require having one of the several extensions
      	to wish that solve this problem.
          2) Leave it like it is now
          3) Write my own Mail command.
      
      The main change would be the speed with which a message is displayed.
      I would appreciate your opinions on this matter.

      When reading the stdout from the Mail command:
        Any ending lines that doesn't begin with a space in the header
        are interpreted as Mail information and discarded.
        All lines at the bottom of a message until the first blank
        (moving up from the end) are interpreted as Mail information.

  BUGS:
      
      The bell doesn't work when the shell TkMail was run from
      is killed. This is because the normal way of sounding the
      bell in Tcl is writing a '\007' to standard out. So until
      Tk supports a bell command, you must either make sure not
      to quit the shell TkMail was run from, or get one of the
      many patches to Tk that implement a bell. I have created
      the user setting of mf(beep) to put an alternate bell command
      if you have one.

      I am sure there are plenty of other bugs in this, so mail me
      about them (raines@bohr.physics.upenn.edu)

  TODO:
      more command line options than iconic, folder
      dynamic user setting with set and save procedure
      add a Help menu
      MIME ( a long way off )
      filtering
      parse .mailrc to merge Mail and TkMail options
      allow alternate editors
      a Send to => menu item in compose
      use autoload or toolbox for utils.tk and ispell.tk
      recognize uuencoded stuff and do something special
      have an unshar

  COPYRIGHT:
      Copyright 1993 by Paul Raines (raines@bohr.physics.upenn.edu)

      Permission to use, copy, modify, and distribute this
      software and its documentation for any purpose and without
      fee is hereby granted, provided that the above copyright
      notice appear in all copies.  The University of Pennsylvania
      makes no representations about the suitability of this
      software for any purpose.  It is provided "as is" without
      express or implied warranty.

  DISCLAIMER:
      UNDER NO CIRCUMSTANCES WILL THE AUTHOR OF THIS SOFTWARE OR THE
      UNIVERSITY OF PENNSYLVANIA BE RESPONSIBLE FOR ANY DIRECT OR
      INCIDENTAL DAMAGE ARISING FROM THE USE OF THIS SOFTWARE AND ITS
      DOCUMENTATION. THE SOFTWARE HEREIN IS PROVIDED "AS IS" WITH NO
      IMPLIED OBLIGATION TO PROVIDE SUPPORT, UPDATES, OR MODIFICATIONS.

  HISTORY:
    v1.0 alpha
      93-05-19    released original version

    v1.0 alpha r1
      93-05-19    insert file no longer uses prefix
      	    Re: now works correctly

    v1.0 alpha r2
      93-05-21    fixed bug in mf_delete with finding closest undeleted mesg
      	    fixed yview's to use mf(curtndx)

    v1.0
      93-05-28    fixed bug where $mf(cmd) was not used everywhere
      93-05-29    fixed bug in Next and Prev
      	    directed bell to stderr
      	    fixed system folder stat bug (thanks Dan Schenck)
      	    changed sendmsg to use sendmail so headers can be included
      	    fixed bug with calling selmesg after delmesg
      	    sendmail now in background, tabbing in compose
      	    reverse order available, user def file sourced
      	    implemented mf_compose_hook, itegrated tkispell
      	    added Gripe
      93-05-30    x-y posting of alert and getstring

    v1.1
      93-05-31    fixed compose window bug with xpos

    v1.2
      93-05-31    forward now uses $mf(deliver)
      	    now keeps directories out of listed folders

      93-06-02    Put checkmail before setup on startup so iconic option works
      	    Fixed getopts and Main Box menu item to allow user to specify
      	       a main box other than ~/mbox
      	    Changed incorporate mail to use "s" instead of "mb" 
      	    Implemented mf_recordmsg
      93-06-03    Got rid of update idletasks, put in alternate bell ability
      	    Implemented getting number of message in system box.

Please mail any suggestions, bugs, whines to raines@bohr.physics.upenn.edu
The latest version is available by anonymous ftp at
      bohr.physics.upenn.edu:pub/tk/tkmail.tk.Z

