procmail
[Top] [All Lists]

Re: using MATCH for getting folder destination names

1996-12-16 02:56:24
On Mon, 16 Dec 1996, Tony Nugent wrote:

    > I'm running procmail on my linux box, and it does a great job.  (No,
    > it does a *fantastic* job! :)  I'm subscribed to several linux email
    > lists and use procmail to put these messages into mh folders which
    > have names based on the name of the respective list.  (I've found
    > mh to be a very good mailreading package).
    > 
    > For example, `linux-net' goes into ~/Mail/net/., `linux-admin' goes into
    > ~/Mail/admin/. and so on.
    > 
    > At the moment I have separate delivering recipes for each list, for
    > example:
    > 
    >  # linux-admin
    >  :0H:
    >  * (^From[^:]|^Cc:|^To:).*linux-(admin|dev-admin)
    >  admin/.
    >  #
    >  # linux-net
    >  :0H:
    >  * (^From[^:]|^Cc:|^To:).*linux-(net|dev-net)
    >  net/.
    >  #
    >  # linux-ppp
    >  :0H:
    >  * (^From[^:]|^Cc:|^To:).*linux-(ppp|dev-ppp)
    >  ppp/.
    >  #
    >  # linux-svgalib
    >  :0H:
    >  * (^From[^:]|^Cc:|^To:).*linux-(svgalib|dev-svgalib)
    >  svgalib/.
    > 
    > and so on.
    > 
    > However, after thinking about this, I realised that all these recipes
    > are very similar and that using the `MATCH' variable might make it
    > possible for me to greatly simplify things so that *one* recipe is
    > used for delivering messages from each of these lists!
    > 
    > Something along the lines of:
    > 
    > :0
    > * (^From[^:]|^Cc:|^To:).*linux-.*(-|@)
    > $MATCH/.
    > 
    > My question is if this is possible.  I'm sure it is, but how?
    > 
    > I'm not sure exactly how the word in $MATCH is obtained, how
    > to make sure that what I get is exactly what I want (I could change
    > the names of some of my folders to make a match), and if this would
    > be a "foolproof" method of doing what I want.
    > 
    > In the above example matching rule, I have `*linux-.*(-|@)' so the the
    > next word after `linux-' and before the next `-' and `@' characters is
    > matched.  But what I have there now won't work as it is, since
    > anything _before_ `linux-' is also matched.
    > 
    > Or is it?  I'm confused :)
    > 
    > The names of the linux lists I'm subscribed to include:
    > 
    > linux-alert     linux-announce linux-ggi linux-security linux-kernel
    > linux-admin     linux-smp      linux-pro linux-admin    linux-x11
    > linux-standards linux-serial   linux-ftp linux-apps     linux-sound
    > linux-config    linux-console  linux-gcc linux-net      linux-ppp
    > linux-svgalib   linux-tape     linux-c-programming
    > 
    > In addition, matches need to be made on strings that look like
    > `owner-linux-(list)', `(list)-linux-digest', or
    > `submit-linux-dev-(list)@', etc.
    > 
    > A further complication is that I get at least two of these lists
    > (linux-admin and linux-kernel) as digests, and I then have recipes
    > that use procmail/formail to explode these for me into separate
    > messages.
    > 
    > Any suggestions for some nifty recipes to do this are most welcome, as
    > it would shrink my ~/.procmailrc by at least 75% and make reading and
    > maintaining it a whole lot easier!

Please read the procmail tutorial which explains a "prefiling" 
method I use for just the problem you are describing.  This
tutorial and the recipes it describes are available from my procmail 
recipe library, which you can obtain by sending me a mail with
the subject of "send procmail library", or by browsing my
web page under the "mail" or "depot" links.

Here is a small snippet from my own .procmailrc to do this kind of
prefiling:

  ...
  ADDR=procmail                 DEST=info/procmail/.    INCLUDERC=mh-check.rc
  ADDR=SmartList                DEST=info/smartlist/.   INCLUDERC=mh-check.rc
  ADDR=mh-e(_at_)x(_dot_)org            DEST=info/mh/.          
INCLUDERC=mh-check.rc
  ...
  # Finally, after all that, save the message 
  INCLUDERC=mh-save.rc

Enjoy.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

<Prev in Thread] Current Thread [Next in Thread>