Using procmail to filter and MH to read (summary)
I wrote:
> Suppose I use procmail as my delivery agent (instead of deliver)
> and MH (actually mh-e in Emacs) to read mail.
>
> What do people do to separate out (filter) the Debian mailing?
Andy Kahn <kahn@zk3.dec.com> suggested I redirect to a file using
this in ~/.procmailrc
:0 f
* ^To: debian-user@lists.debian.org
debian
Dima <dima@eris.dev.null> suggested MH's own folder refiler like this
in ~/.procmailrc:
:0:$MAILDIR/debian-user/.mh_sequences.$LOCKEXT
* ^FROMdebian-user.*
| /usr/lib/mh/rcvstore +debian-user
What I decided to do is to mail file to a second file (a spool file) such
that:
- I can download a copy from home using my PC's POP server.
- I can use an xbiff-like program to notify me of new mail.
So my filter looks like:
-- ~/.procmailrc --
MAILDIR=/var/spool/mail
:0
* ^From debian-user-request@lists.debian.org
debian
-- ~/.procmailrc --
I wrote the following elisp code for Emacs to incorporate my newmail
simply by pressing `D' in a folder buffer.
Peter
-- e-mh-inc-procmail.el --
;; e-mh-inc-procmail --- inc(orporate) filtered mail into a specific folder
;; Copyright (C) 1994, 1995, 1996, 1997 Peter S. Galbraith
;; Author: Peter S. Galbraith <galbraith@mixing.qc.dfo.ca>
;; Created: 12 Aug 1997
;; Version: 1.00 (12 Aug 97)
;; Keywords: mh-e, procmail, Debian
;; RCS $Id: e-mh-inc-procmail.el,v 1.4 1997/08/12 20:17:34 rhogee Exp $
;; Note: RCS version number does not correspond to release number.
;;; This file is not part of GNU Emacs.
;; This package is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This package is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; ----------------------------------------------------------------------------
;;; Commentary:
;; This minor hack is made to ease the use of mh-e when procmail is used to
;; filter a mailing list, by providing a quick way to `inc' the mailing
;; list's mail into a folder.
;; Usage instructions:
;; ~~~~~~~~~~~~~~~~~~
;; Use the `D' key in any e-mh folder to switch to your procmail folder
;; and incorporate new mail.
;;
;; The advantage to leaving mail on a spool file rather than using
;; a filter pipe to something like
;; | /usr/lib/mh/rcvstore +Debian
;; is that (1) I can use fetchmail from home to get a copy of the mail
;; and (2) I can use an xbiff-like program to monitor the mail spool, e.g.
;;
;; xbuffy -orig -acmd "/usr/X11R6/bin/auplay
;; /usr/lib/tkdesk/sounds/newmail.au"
;; -poll 10 -header 3
;; -command "gnudoit -q '(e-mh-inc-procmail)'"
;; /var/spool/mail/debian
;; Installation instructions:
;; ~~~~~~~~~~~~~~~~~~~~~~~~~
;; Create a ~/.procmailrc filter to send your mailing list's mail to
;; a file (See `C-h v e-mh-inc-procmail-mail-file' for details).
;;
;; setq the variables `e-mh-inc-procmail-mail-file' and
;; `e-mh-inc-procmail-folder' according to your re-routed spool file and
;; selected MH folder. e.g. put something like this in your ~/.emacs
;; (setq e-mh-inc-procmail-mail-file "~/Mail/debian-mail"
;; e-mh-inc-procmail-folder "+Debian")
;;
;; In the default settings, I read in /var/spool/mail/debian into the
;; +Debian folder.
;; ----------------------------------------------------------------------------
;;; Change log:
;; V1.00 August 12 97 - Peter Galbraith - Created
;;; Code:
(defvar e-mh-inc-procmail-mail-file "/var/spool/mail/debian"
"Path to my Debian mail file, as filtered by procmail.
Use a procmail filter like so:
MAILDIR=/var/spool/mail
:0
* ^From debian-user-request@lists.debian.org
debian
")
(defvar e-mh-inc-procmail-folder "+Debian"
"MH Folder used for the procmail filtered mailing list.")
(defun e-mh-inc-procmail ()
"Inc(orporate)s new Debian mail into the Debian folder"
(interactive)
(cond
((eq 0 (elt (file-attributes e-mh-inc-procmail-mail-file) 7))
(message "No new Debian mail"))
(t
(let ((config (current-window-configuration)))
(cond ((not (get-buffer e-mh-inc-procmail-folder))
(mh-make-folder e-mh-inc-procmail-folder)
(setq mh-previous-window-config config))
((not (eq (current-buffer) (get-buffer e-mh-inc-procmail-folder)))
(switch-to-buffer e-mh-inc-procmail-folder)
(setq mh-previous-window-config config))))
(mh-get-new-mail e-mh-inc-procmail-mail-file)
(run-hooks 'mh-inc-folder-hook))))
(define-key mh-folder-mode-map "D" 'e-mh-inc-procmail)
(provide 'e-mh-inc-procmail)
;;; e-mh-inc-procmail ends here
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: