On January 5, [EMAIL PROTECTED] said:
> 
> However, I've found the source to bbdb-ignore-most-messages-hook, so I may
> be able to figure it out from here.  (I'd originally done a grep on the
> bbdb files, but I'd forgotten that Debian compresses all of the .el's, so
> grep didn't find much.  zgrep works much better here....)
> 
> Richard

To clarify (shame on you, richard, for not sharing!): when
bbdb/mail-auto-create-p is a function, it is called when the current
buffer is set to the currently viewed message. This allows you to do
whatever you like to determine if you should add a record or not:
looking for spam keywords in the message body is probably a good
example. Below is the  function I use myself which simply filters
things not addressed directly to me via To: or Cc:, and then passes
control to bbdb-ignore-some-messages-hook.

Cheers,
Waider.

(defun bbdb-add-record-hook()
  "Function called when bbdb is trying to automatically create a record."
  ;; Here goes code to prune when To != waider@
  (let ((case-fold-search t)
        (done nil)
        (b (current-buffer))
        (marker (bbdb-header-start))
        field regexp fieldval)
    (set-buffer (marker-buffer marker))
    (save-excursion
      ;; Hey ho. The buffer we're in is the mail file, narrowed to the
      ;; current message.
      (let (to cc precedence)
        (goto-char marker)
        (setq to (bbdb-extract-field-value "To"))
        (goto-char marker)
        (setq cc (bbdb-extract-field-value "Cc"))
        (goto-char marker)
        (setq precedence (bbdb-extract-field-value "Precedence"))
        (if (and (not (string-match "waider@" (or to "")))
                 (not (string-match "ronan.waide" (or to "")))
                 (not (string-match "waider@" (or cc "")))
                 (not (string-match "ronan.waide" (or cc ""))))
            (progn
              (message "BBDB unfiling; message to: %s cc: %s"
                       (or to "noone") (or cc "noone"))
              ;; Return nil so that the record isn't added.
              nil)

          (if (string-match "junk" (or precedence ""))
              (progn
                (message "precedence set to junk, bbdb ignoring.")
                nil)

            ;; Otherwise add, subject to filtering
            (bbdb-ignore-some-messages-hook)))))))

-- 
[EMAIL PROTECTED] / Yes, it /is/ very personal of me.

I really need to reinstate the witty comments, dammit.


_______________________________________________
bbdb-info mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/bbdb-info

Reply via email to