emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changes in Headers in RMAIL


From: Henrik Enberg
Subject: Re: Changes in Headers in RMAIL
Date: Wed, 15 Nov 2006 20:10:37 +0100 (CET)

> Date: Wed, 15 Nov 2006 20:14:07 +0200
> From: Eli Zaretskii <address@hidden>
> 
> > Date: Wed, 15 Nov 2006 17:59:21 +0000
> > From: <address@hidden>
> > 
> > For some time I have had a mail filter that works by looking at the
> > headers.  The problem is that with the new version the particular
> > headers seem not to be searchable.
> > 
> > In particular 
> > 
> > (defun rmail-file-filtering-mail-hook () 
> >   "Hook to file mail and label spam etc automatically"
> > .....
> >           (setq x-rbl   (mail-fetch-field "X-RBL-Warning"))
> > .....
> >               ((or x-rbl                    ; Sites on RBL
> >                    (string-match "rbl-plus.mail-abuse.ja.net" x-warning)
> >                    (string-match "zen.spamhaus.org" x-warning))
> >                (let ((ss rmail-delete-after-output))
> >                  ....
> >              (rmail-set-attribute "deleted" t)
> >                  .....
> > 
> > but the X_RBL-Warning header is not found despite being there
> 
> I think that's because the X-RBL-Warning header is concealed by
> default.  Does it help to use rmail-narrow-to-non-pruned-header before
> mail-fetch-field?

I use the following macro when I need to look at message headers in an
RMAIL buffer.  It's a bit more convenient than
rmail-narrow-to-non-pruned-header. 

(defmacro with-rmail-message-header (n &rest body)
  (declare (indent 1) (debug t))
  `(with-current-buffer rmail-buffer
     (save-restriction
       (narrow-to-region (rmail-msgbeg ,n) (rmail-msgend ,n))
       (goto-char (point-min))
       ;; maybe skip babyl lines at the beginning
       (when (looking-at "\C-_\C-l")
         (forward-line 2)
         (while (looking-at "Summary-line:\\|X-Coding-System:")
           (forward-line 1))
         (when (looking-at "^\\(Mail-from:[ \t]+\\)")
           (goto-char (match-end 1))))
       (narrow-to-region (point) (1- (search-forward "\n\n")))
       ;; We should now have something similar to the original,
       ;; pre-babylized message header in the current buffer.
       ;; Go to point-min and run BODY.
       (goto-char (point-min))
       ,@body)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]