Subject: Procmail and Emacs

From: Roman Czyborra <[email-masked]>
Date: Sun, 13 Mar 1994 19:36:15 +0100

Frank Caggiano <[email-masked]> wrote:

> 	I've just installed procmail here set to run out of .forward,
> set uid to root and have gotten it to work for me nicely.  I read my
> mail in emacs using rmail and haven't figured out a good way of
> intergrating the two. I'd appreciate any ideas on how to do this.

Emacs and Procmail are incompatible in two respects.  The first is the
Babyl file format in which Rmail stores its messages.  Rmail seems to
be the only mail reader using that weird thing while Procmail sticks
with the traditional Unix mbox format which can be handled by almost
every other mail software.  I suggest you run M-x unrmail on all of
your folders and M-x disable-command rmail.  However that doesn't mean
you have to give up the luxury of using Emacs for reading and writing
mai because there is M-x vm, a Unix-compatible substitute for Rmail,
written by Kyle Jones and part of the standard Emacs distribution (try
C-h i m vm).

If you use VM, another problem remains: file locking.  Emacs has a
fairly primitive file locking mechanism.  When you open a file, Emacs
creates a lockfile in a directory named /usr/emacs/lock or similarly
and keeps it until you're done editing that file.  In many distributed
file systems that option is even turned off.  You should think twice
before you specify /usr/emacs/lock/!home!frank!Mail!folderx as the
local lockfile in your procmailrc because that way mail delivery for
the folder will silently be delayed until you close it.

If you keep a separate folder for a low-traffic mailinglist, you might
try living without any lockfile because Emacs will notice if the file
changed on disk.  But it has no means of merging your buffer contents
with the disk file.  So if new mail comes in while you're reading a
folder, you'll have to discard all your deletions.

The only file that Rmail and VM access with some sort of intelligent
locking (only the read and write are locked) is emptying the mail
spool.  For that purpose they use the undocumented movemail utility.
Because of that I have procmail put all my incoming mail into my spool
box and use it for preprocessing, forwarding and auto-replying only,
but not for selecting different folders.  If I wanted to have all
mail about procmail filed into one folder I could set that in my
vm-auto-folder-alist.

If you run your Emacs on hosts whose internal clock is more than a
minute ahead of your mailserver's, you even risk losing mail because
movemail has a fixed LOCKTIMEOUT of 60 and doesn't double-check the
clock difference.  I've (setq vm-movemail-program "~/bin/movemail")
with ~/bin/movemail being:

#!/bin/sh
lockfile $1.lock || exit
cp $1 $2 && echo -n > $1
rm -f $1.lock

---

From: "John Ladwig" <[email-masked]>
Date: Sun, 13 Mar 94 13:57:37 CST

>>>>> On Sun, 13 Mar 1994 19:36:15 +0100, Roman Czyborra <[email-masked]> said:

    RC> [ ... ] there is M-x vm, a Unix-compatible substitute for Rmail,
    RC> written by Kyle Jones and part of the standard Emacs distribution (try
    RC> C-h i m vm).

Actually, it's *not* in the distribution, but it *might* be in the
future.

VM is available UUNET's ftp archives, in the <a
href="ftp://ftp.uu.net/mail/vm> directory mail/vm</a> as a gzipped tar
file, currently vm-5.64beta.tar.gz

    RC> The only file that Rmail and VM access with some sort of intelligent
    RC> locking (only the read and write are locked) is emptying the mail
    RC> spool.  For that purpose they use the undocumented movemail utility.
    RC> Because of that I have procmail put all my incoming mail into my spool
    RC> box and use it for preprocessing, forwarding and auto-replying only,
    RC> but not for selecting different folders.  If I wanted to have all
    RC> mail about procmail filed into one folder I could set that in my
    RC> vm-auto-folder-alist.

The best way to deal with the poor lock communications in VM is to use
the facility for associating one or more "spool" directories with each
VM mailbox file.  This allows procmail to deliver to one file while
you work with another, until you ask for an update from the "spool"
via movemail.  I use this for a POSTMASTER bounce archive that I deal
with on weekends.

    -jml