Hello

I  will be bold and  ask after  some hours  of  testing to include the
following function into bbdb where ever you think it is appropriate. If
you, Waider, decide that this function will not be included, I will ask
in the gnus list.

Thank you both Ted and Waider

Uwe

--8<------------------------schnipp------------------------->8---

(defun bbdb-nnimap-folder-list-from-bbdb ()
  "Return a list of \( \"From\" email-regexp imap-folder-name\) tuples
based on the contents of the bbdb.

The folder-name is  the  value  of  the  'imap attribute on  the  bbdb
record;  the email-regexp consists of  all the email addresses for the
bbdb record  concatenated with with  OR.  bbdb records without a 'imap
attribute are ignored.  
Here  is an example of a relevant BBDB entry:

Uwe Brauer
            net: [EMAIL PROTECTED]
           imap: testimap


This function  uses  regexp-opt  to  generate  the email-regexp  which
automatically regexp-quotes  its arguments. Please  note: in oder that
this will   work with the nnimap-split-fancy   method you have  to use
macros, that is your setting will look like:

\(setq
 nnimap-split-rule  'nnimap-split-fancy
 nnimap-split-inbox \"INBOX\"
 nnimap-split-fancy
 `\(|
   ,@\(bbdb-nnimap-folder-list-from-bbdb\)
   ...
\)\)
Note that `\( is the backquote NOT the quote '\(. "

;(interactive)
  (let (;; the raw-notes attribute of a bbdb record
        notes-attr
        ;; the value of the 'imap attribute of a bbdb record
        folder-attr
        ;; strings to put before and after the folder-attr
        (folder-prefix "")
        (folder-postfix "")
        ;; a regexp matching all the email addresses from a bbdb record
        email-regexp
        ;; the list of (folder email) tuples to return
        new-elmnt-list
        )
    ;; loop over the bbdb-records; if a imap attribute exists on
    ;; the record, generate a regexp matching all the email addresses
    ;; and add a tuple (folder email-regexp) to the new-elmnt-list
    (dolist (record (bbdb-records))
      (setq notes-attr (bbdb-record-raw-notes record))
      (when (and (listp notes-attr)
                                 (setq folder-attr (cdr (assq 'imap 
notes-attr))))
        (setq email-regexp (regexp-opt (mapcar 'downcase 
                                               (bbdb-record-net record))))
        (unless (zerop (length email-regexp))
          (setq new-elmnt-list
                (cons (list "From" email-regexp (concat folder-prefix
                folder-attr folder-postfix)) 
                      new-elmnt-list)))))
    new-elmnt-list))

--8<------------------------schnapp------------------------->8---



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to